|
下面是我的代码,想实现1s定时,不知道为何不行
int isTimer=1;
void
Timer0_ISR(void) //函数名请问有什么要求么?我看有的教程用的是Timer0_ISR,青风的教程用的是Timer0IntHandler,我试了两种都不行
{
isTime = 1;
HWREGBITW(&g_ulFlags, 0) ^= 1;
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
}
int main(void){
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
IntMasterEnable();
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
while(1){
if(isTime){
TimerConfigure(TIMER0_BASE, TIMER_CFG_ONE_SHOT);
TimerLoadSet(TIMER0_BASE, TIMER_A, 4000000UL);
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER0_BASE, TIMER_A);
}
}
}
|
|