SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // 使能 GPIO B模块
GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinConfigure(GPIO_PB2_T3CCP0); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
TimerConfigure(TIMER3_BASE, TIMER_CFG_A_CAP_COUNT_UP|TIMER_CFG_B_CAP_COUNT_UP);//
TimerEnable(TIMER3_BASE, TIMER_A);
书上说定时器配成了24/48位计数器
但是TimerConfigure具体要怎么配呢
组合好多参数,TBR的寄存器都没有变化,TAR能够正常计数
DC SUE:
或者谁能发一下32位WTIMER的输入计数配置的代码吗,写了快一天了
DC SUE:
回复 DC SUE:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6); GPIOPinConfigure(GPIO_PD6_WT5CCP0); GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_6); SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER5);
TimerConfigure(WTIMER5_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP)); TimerLoadSet(WTIMER5_BASE, TIMER_A, 0xffffffff-1); TimerEnable(WTIMER5_BASE, TIMER_A);
问题还是没解决,但是用了个32位的代替了
DC SUE:
回复 DC SUE:
顺便问一下,输入计数的模式下有专门清除TAR寄存器的函数吗
xyz549040622:
回复 DC SUE:
好像没有这个专门的函数,你可以操作寄存器来试试。
yanyousheng Yan:
回复 DC SUE:
你那个TimerConfigure应该是被重新定义了,原函数应该是这个:希望能够帮到你
21.2.1 Function Documentation21.2.1.1 ROM_TimerConfigureConfigures the timer(s).Prototype:voidROM_TimerConfigure(uint32_t ui32Base,uint32_t ui32Config)ROM Location:ROM_APITABLE is an array of pointers located at 0x0100.0010.ROM_TIMERTABLE is an array of pointers located at ROM_APITABLE[11].ROM_TimerConfigure is a function pointer located at ROM_TIMERTABLE[3].Parameters:ui32Base is the base address of the timer module.ui32Config is the configuration for the timer.Description:This function configures the operating mode of the timer(s). The timer module is disabledbefore being configured, and is left in the disabled state. There are two types of timers; a16/32-bit variety and a 32/64-bit variety. The 16/32-bit variety is comprised of two 16-bit timers230 May 14, 2014Tiva TM4C123x ROM User’s Guidethat can operate independently or be concatenated to form a 32-bit timer. Similarly, the 32/64-bit variety is comprised of two 32-bit timers that can operate independently or be concatenatedto form a 64-bit timer.The configuration is specified in ui32Config as one of the following values:TIMER_CFG_ONE_SHOT – Full-width one-shot timerTIMER_CFG_ONE_SHOT_UP – Full-width one-shot timer that counts up instead of down(not available on all parts)TIMER_CFG_PERIODIC – Full-width periodic timerTIMER_CFG_PERIODIC_UP – Full-width periodic timer that counts up instead of down(not available on all parts)TIMER_CFG_RTC – Full-width real time clock timerTIMER_CFG_SPLIT_PAIR – Two half-width timersWhen configured for a pair of half-width timers, each timer is separately configured. The firsttimer is configured by setting ui32Config to the result of a logical OR operation between one ofthe following values and ui32Config:TIMER_CFG_A_ONE_SHOT – Half-width one-shot timerTIMER_CFG_A_ONE_SHOT_UP – Half-width one-shot timer that counts up instead ofdown (not available on all parts)TIMER_CFG_A_PERIODIC – Half-width periodic timerTIMER_CFG_A_PERIODIC_UP – Half-width periodic timer that counts up instead of down(not available on all parts)TIMER_CFG_A_CAP_COUNT – Half-width edge count captureTIMER_CFG_A_CAP_COUNT_UP – Half-width edge count capture that counts up insteadof down (not available on all parts)TIMER_CFG_A_CAP_TIME – Half-width edge time captureTIMER_CFG_A_CAP_TIME_UP – Half-width edge time capture that counts up instead ofdown (not available on all parts)TIMER_CFG_A_PWM – Half-width PWM outputSimilarly, the second timer is configured by setting ui32Config to the result of a logical ORoperation between one of the corresponding TIMER_CFG_B_∗ values and ui32Config.Returns:None.