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.

TM4C123GH6PM中的PWM的周期、频率怎么设置的?

Other Parts Discussed in Thread: TM4C123GH6PM

TM4C123GH6PM中的PWM的周期、频率设置感到很复杂,没有理清楚。还有就是看到文档中讲解系统频率配置时,配置为

ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);解释为40MHz,有点疑惑,希望工程师能够指点一下,谢谢啦!

  • 指的是啥PWM?定时器出的还是PWM module输出的?

    定时器出PWM在C:\ti\TivaWare_C_Series-2.1.0.12573\examples\peripherals\timer\pwm.c

    PWM Module出的在C:\ti\TivaWare_C_Series-2.1.0.12573\examples\peripherals\pwm路径下。

    时钟的话,PLL会把时钟先倍到200MHz。那么上面的5分频就是40MHz,如果需要80MHZ就是2.5分频,使用宏定义SYSCTL_SYSDIV_2_5

  • 您好!我用的是PWM module输出的,关于周期频率计算感到有点困惑,比如在系统时种下,要得到一定的周期频率,以及要得到的占空比的计算数值等的计算有点困惑。顺便问一下,系统时钟最高可以以多打频率运行?非常感谢!

  • TM4C123x的最高主频可以配置为80MHz。TM4C129x是120.

    针对PWM的使用,参考源码:

    //
    // Set the PWM period to 250Hz. To calculate the appropriate parameter
    // use the following equation: N = (1 / f) * SysClk. Where N is the
    // function parameter, f is the desired frequency, and SysClk is the
    // system clock frequency.
    // In this case you get: (1 / 250Hz) * 16MHz = 64000 cycles. Note that
    // the maximum period you can set is 2^16 - 1.
    // TODO: modify this calculation to use the clock frequency that you are
    // using.
    //
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 64000);

    //
    // Set PWM0 PD0 to a duty cycle of 25%. You set the duty cycle as a
    // function of the period. Since the period was set above, you can use the
    // PWMGenPeriodGet() function. For this example the PWM will be high for
    // 25% of the time or 16000 clock cycles (64000 / 4).
    //
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,
    PWMGenPeriodGet(PWM0_BASE, PWM_OUT_0) / 4);

    这里阐述的很清楚了。注意PWM定时器是16bit的,所以最大值不能大于65535,就是2的16次方减一

  • 想请问下,如果我系统时钟设置为80MHz,要输出频率为800hz,那定时就得设置(1/800)*80MHz不就超过65535了吗?应该怎么设置?我用过定时器产生PWM,也是有相同情况,用预分频了,可脉宽应当怎么调整?

  • 我也再用这款微控制器,是来操作一个4相步进电机的,要写程序,谁会写啊。写Timer和pwm,stepper的程序,求指教啊,再次先谢过了。