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:WideTimer0 PWM:无需预分频?

Guru**** 2454880 points


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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/639007/tm4c123gh6pm-widetimer0-pwm-no-need-for-prescale

器件型号:TM4C123GH6PM

您好!  

 我将使用 EK-TM4C123 Launchpad 和 CCS 7、并在占空比较短的情况下对 PWM 进行一些长时间实验。

 我在 PWM 模式中使用 WTIMER 0作为2半计数器。   根据 MCU Tiva TM4CGH6PM 的数据表(2013年7月13日版)、在713页上、我们 有24位每半个计数器。 (Timer_A、Timer_B)。  

这意味着如果计数超过该值、我们需要使用预分频寄存器。   

  我使用的是80MHz 系统时钟、并将周期设置为16秒   为此、要加载的初始计数为  0x4C4B3FFF。

  如果我正确理解数据表、我需要将   0x4B3FFF 加载到 TIMER_TAILR/TIMER_TBILR 并将0x4C 加载到预分频器寄存器 TIMPER_TxPR、还需要相应地加载匹配和预匹配寄存器。  

  但是、当我进行实验时、我不必在我的代码中执行该操作。

  以下是我的代码:

     

#include
#include
#include "inc/tm4c123gh6m.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include "inc/hw_timer.h"

uint32_t g_ui32Period;

void main (void){
SysCtlClockSet (SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHz);

SysCtlPeripheralEnable (SYSCTL_Periph_GPIOC);
SysCtlDelay(3);
GPIOPinConfigure (GPIO_PC5_WT0CCP1);
GPIOPinTypeTimer (GPIO_PORTC_BASE、GPIO_PIN_5);
GPIOPinConfigure (GPIO_PC4_WT0CCP0);
GPIOPinTypeTimer (GPIO_PORTC_BASE、GPIO_PIN_4);

SysCtlPeripheralEnable (SYSCTL_Periph_WTIME0);
SysCtlDelay(3);

TimerConfigure (WTIMER 0_BASE、TIMER_CFG_SPLIT_PAIRGE|TIMER_CFG_A_PWM|TIMER_CFG_B_PWM);


G_ui32Period =16*(SysCtlClockGet ());// 8*(SysCtlClockGet ()/ 1)/1;//

TimerLoadSet (WTIMER 0_BASE、TIMER_A、g_ui32Period-1);
TimerMatchSet (WTIMER 0_BASE、TIMER_A、g_ui32Period*0.5-40);


TimerLoadSet (WTIMER 0_BASE、TIMER_B、g_ui32Period-1);
TimerMatchSet (WTIMER 0_BASE、TIMER_B、g_ui32Period*0.5+40);
TimerControlLevel (WTIMER 0_BASE、TIMER_B、TRUE);


HWREG (WTIMER 0_BASE_TIMER_TBMR_TBMRSU)=1;//仅在下一次超时后更新
HWREG (WTIMER 0_BASE_TIMER_TAMR_TAMRSU)=1;//仅在下一次超时后更新

TimerEnable (WTIMER 0_BASE、TIMER_Both);

while (1){



 

   请查看我的代码和下面的寄存器视图、并就此提供建议。

   提前感谢。