EFM32 Timer 테스트 - 타이머 인터럽트로 1초 만들기
EFM32 Timer 초기화 함수
void InitTimer0(void)
{
// Enable clock for TIMER0 module
CMU_ClockEnable(cmuClock_TIMER0, true);
//Select TIMER0 parameters
TIMER_Init_TypeDef timerInit =
{
.enable = true,
.debugRun = true,
.prescale = timerPrescale1024,
.clkSel = timerClkSelHFPerClk,
.fallAction = timerInputActionNone,
.riseAction = timerInputActionNone,
.mode = timerModeUp,
.dmaClrAct = false,
.quadModeX4 = false,
.oneShot = false,
.sync = false,
};
// Enable overflow interrupt
TIMER_IntEnable(TIMER0, TIMER_IF_OF);
// Enable TIMER0 interrupt vector in NVIC
NVIC_EnableIRQ(TIMER0_IRQn);
// Set TIMER Top value - Top Value / (28MHz / 1024 (prescaler))
// For 1 Seconds Top Value= 27344
TIMER_TopSet(TIMER0, 27344);
/* Configure TIMER */
TIMER_Init(TIMER0, &timerInit);
}
EFM32 타이머 인터럽트 핸들러
void TIMER0_IRQHandler(void)
{
//Clear flag for TIMER0 overflow interrupt
TIMER_IntClear(TIMER0, TIMER_IF_OF);
Led1Toggle();
}