void Timer0_Init(void)
{
/* Enable IP clock */
CLK_EnableModuleClock(TMR0_MODULE);
/* Select IP clock source */
CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0_S_HXT, 0);
// Set timer frequency to 10Hz
TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 10);
// Enable timer interrupt
TIMER_EnableInt(TIMER0);
NVIC_EnableIRQ(TMR0_IRQn);
// Start Timer 0
TIMER_Start(TIMER0);
}
void TMR0_IRQHandler(void)
{
if(flag == 0)
{
flag = 1;
LED_UP_GREEN = 0;
LED_UP_RED = 1;
}
else
{
flag = 0;
LED_UP_GREEN = 1;
LED_UP_RED = 0;
}
// clear timer interrupt flag
TIMER_ClearIntFlag(TIMER0);
}
调试发现初始化的后三句,根本没有执行,不知道什么原因 |