这里是初始化程序啊。
帮忙看看吧。
/*
函数:widetimer0_set
功能:设置widetimer0定时器A为定时器,B为计数器
参数:
period : 定时器递减计数周期
*/
void widetimer0_set(int32_t period,void (*pfnHandler)(void))
{
/*使能外设*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
/*widetimer0 的timer0A为定时,B为计数*/
TimerConfigure(WTIMER0_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC |TIMER_CFG_B_CAP_COUNT_UP));
/*设置定时器同步*/
TimerSynchronize(WTIMER0_BASE,WTIMER_0A_SYNC|WTIMER_0B_SYNC);//
/*装填定时周期*/
TimerLoadSet(WTIMER0_BASE,TIMER_A,period);
/*装填计数初始值*/
// TimerLoadSet(WTIMER0_BASE,TIMER_B,2);
/*注册中断*/
TimerIntRegister(WTIMER0_BASE,TIMER_A,pfnHandler);
/*打开NIVC中断屏蔽*/
IntEnable(INT_WTIMER0A);
/*使能定时器中断*/
TimerIntEnable(WTIMER0_BASE, TIMER_TIMA_TIMEOUT);
/*打开CPU中断响应*/
IntMasterEnable();
/*设置捕获引脚*/
GPIOPinTypeTimer(GPIO_PORTC_BASE,5);
GPIODirModeSet(GPIO_PORTC_BASE,5,GPIO_DIR_MODE_IN);
/*设置计数器B的计数方式为上升沿触发*/
TimerControlEvent(WTIMER0_BASE, TIMER_B, TIMER_EVENT_POS_EDGE);
/*启动定时器A.B*/
TimerEnable(WTIMER0_BASE, TIMER_BOTH);
}