/*---------------------------------------------------------------------------------------- 函数名: TimerInit 参数: None 返回值: None 描述: 初始化定时器,并创建第一个虚拟定时器:1s为周期 ----------------------------------------------------------------------------------------*/ void TimerInit(void) { DrvTIMER_Init(); DrvTIMER_Open(TMR1, 1000, PERIODIC_MODE); DrvTIMER_SetTimerEvent(TMR1,1000, (TIMER_CALLBACK)TMRCBForSysTick,0); DrvTIMER_EnableInt(TMR1); DrvTIMER_Ioctl(TMR1, TIMER_IOC_START_COUNT, 0); }
void TIMER_Configuration() { DrvTIMER_Init(); DrvSYS_SelectIPClockSource(E_SYS_TMR0_CLKSRC,0); DrvTIMER_Open(E_TMR0,5,E_PERIODIC_MODE); DrvTIMER_SetTimerEvent(E_TMR0,1,(TIMER_CALLBACK) Timer0_Callback,0); DrvTIMER_EnableInt(E_TMR0); DrvTIMER_Start(E_TMR0); }
/*************************************************************************//** * @brief Delay 1 second exactly with timer. * @param None * @return None *****************************************************************************/ void Delay1Sec(void) { UNLOCKREG(); SYSCLK->PWRCON.XTL12M_EN = 1; /* Waiting for 12M Xtal stable */ while (DrvSYS_GetChipClockSourceStatus(E_SYS_XTL12M) != 1); /*Configure gpio p3.6 as OUTPUT for led*/ DrvGPIO_Open(E_PORT3, E_PIN6, E_IO_OUTPUT); /* Example code */ DrvTIMER_Init(); DrvTIMER_Open(E_TMR0, 1000, E_PERIODIC_MODE); DrvTIMER_EnableInt(E_TMR0); DrvTIMER_Start(E_TMR0); /* Start counting */ while (1) { DrvGPIO_SetBit(E_PORT3, E_PIN6); DrvTIMER_Delay(E_TMR0, 1000); /*Delay 1000/1000 Sec*/ DrvGPIO_ClrBit(E_PORT3, E_PIN6); DrvTIMER_Delay(E_TMR0, 1000); } }