This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] EK-TM4C1294XL:未发生 PWM 输出-反相

Guru**** 2478765 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/696957/ek-tm4c1294xl-pwm-output---inverting-is-not-occurring

器件型号:EK-TM4C1294XL

您好!

我遇到了反相 PWM 的问题。 我使用示波器来查看我的输出、它们完全相同、而我尝试使它们彼此相反。 有什么想法可以导致这个问题?

//Check 模式并相应地设置频率
// if (operatingMode = 0)//Legacy
//{
节拍数= 2000;//4000;//30kHz
//}
//else if (operatingMode = 1)//Smart
//{
// tick = number_tectces_Freq ();
//}

//
//启用 PWM 使用的 GPIO 外设(PF0、PF1)
//
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);

//
//启用 PWM0
//
SysCtlPeripheralEnable (SYSCTL_Periph_PWM0);

while (!SysCtlPeripheralReady (SYSCTL_Periph_GPIOF)){};

//
//将时钟分频以供 PWM 使用-现在将使用一个
//
SysCtlPWMClockSet (SYSCTL_PWMDIV_1);

//
//解锁引脚
//
HWREG (GPIO_PORTF_BASE + GPIO_LO_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTF_BASE + GPIO_O_CR)= 0x01;

//
//为 PWM 配置 GPIO 引脚
//
GPIOPinConfigure (GPIO_PF0_M0PWM0);
GPIOPinConfigure (GPIO_PF1_M0PWM1);

GPIOPinTypePWM (GPIO_PORTF_BASE、GPIO_PIN_0 | GPIO_PIN_1);

//
//配置 PWM
//
PWMGenConfigure (PWM0_BASE、PWM_GEN_0、PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);

//
//设置 PWM 周期
//
PWMGenPeriodSet (PWM0_BASE、PWM_GEN_0、tick);

//
//设置占空比
//
PWMPulseWidthSet (PWM0_BASE、PWM_OUT_0、ceil (tick /2));//50%占空比
PWMPulseWidthSet (PWM0_BASE、PWM_OUT_1、ceil (tick /2));//50%占空比

//
//启用 PWM
//
PWMGenEnable (PWM0_BASE、PWM_GEN_0);
PWMOutputInvert (PWM0_BASE、PWM_OUT_1_BIT、TRUE);
PWMOutputState (PWM0_BASE、PWM_OUT_0_BIT | PWM_OUT_1_BIT、TRUE);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我看到的唯一问题是在 PWMPulseWidthSet()函数中使用"ceil (ticks)"。