我想配置timer0B为检测计数下降沿,从t0ccp0输入,按如下配置的,为什么不能正常工作,DEBUG时发现timer0B完全没有计数
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
TimerConfigure(TIMER0_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC |TIMER_CFG_B_CAP_COUNT));
TimerLoadSet(TIMER0_BASE, TIMER_A, 3000);
TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE);
TimerLoadSet(TIMER0_BASE, TIMER_B, 3000);
TimerMatchSet(TIMER0_BASE,TIMER_B,2000);
IntEnable(INT_TIMER0B);
TimerIntEnable(TIMER0_BASE, TIMER_CAPB_MATCH);
IntMasterEnable();
TimerEnable(TIMER0_BASE, TIMER_B);
Wellin Zhang:
Guangyao
没有对相应的IO进行配置请对使用到的GP6进行如下配置。
// T0CCP0 is used with port B pin 6. Enable GPIOB. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // GPIOB_pin_6 muxing for the Timer/CCP function. GPIOPinConfigure(GPIO_PB6_T0CCP0); // Configure GPIOB_pin_6 for CCP pin. GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);
Guangyao Deng:
回复 Wellin Zhang:
明白了,多谢!