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.

LM4F120H5QR产生PWM的问题



STELLARISWARE里面有产生PWM的例程,但又一处不是很明白.

以下是文档原画:

The generator blocks are called Gen0, Gen1, Gen2 and Gen3.
The two PWM output signals associated with each generator block are called OutA and OutB.
The output signals are called PWM0, PWM1, PWM2, PWM3, PWM4, PWM5, PWM6 and
PWM7.
PWM0 and PWM1 are associated with Gen0, PWM2 and PWM3 are associated with Gen1,
PWM4 and PWM5 are associated with Gen2 and PWM6 and PWM7 are associated with
Gen3.

我的疑问是GEN0,1,2,3怎么和通用定时器对应起来??找了好多文档也没找到其中的关系,查看了PWM.H,PWM.C这两个文件也看出来这PWM和通用定时器有关...

难道有单独的PWM模块????????????????????

PF1口对应的是通用定时器0的TIMERB的比较输出.那我要启用它应该是启用哪个??GEN0?GEN1???我试了GEN0不管...

  •   ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |           //80mhz
                           SYSCTL_OSC_MAIN);
      SysCtlPWMClockSet(SYSCTL_PWMDIV_8);   //10MHZ
     
      SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
     
      GPIOPinConfigure(GPIO_PF1_T0CCP1);
     
      GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);   //PF1
     
      PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
     
      PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 10000);  //1khz
     
      PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 3000);
     
      PWMOutputState(PWM_BASE, PWM_OUT_0_BIT, true);
     
      PWMGenEnable(PWM_BASE, PWM_GEN_0);

    让PF1输出,这个应该做何修改呢??

  • 明白了...LM4F120上没有PWM模块...好吧..

  • 如果需要输出PWM而且要求不是很高的话,可以考虑使用TIMER输出