adapted working code to KED implementation

redesign_interrupts
polymurph 3 years ago
parent 25678fc81e
commit 6270a581b4

@ -60,7 +60,7 @@ void TIM2_IRQHandler(){
if (TIM2->SR & TIM_SR_UIF) if (TIM2->SR & TIM_SR_UIF)
{ {
/* Clear the interrupt even flag. CPU will only respond to new flags thereafter */ /* Clear the interrupt even flag. CPU will only respond to new flags thereafter */
TIM2->SR &= ~(TIM_SR_UIF); TIM2->SR &= ~TIM_SR_UIF;
pinToggle(pinB3); pinToggle(pinB3);
} }
} }
@ -124,6 +124,7 @@ void LEDtoggleOnTimer2underflow()
} }
*/ */
#if 0
// example based on // example based on
// https://alsaibie.github.io/me319/prelabsextra/lab4extra/ // https://alsaibie.github.io/me319/prelabsextra/lab4extra/
/* Enable Timer 2 peripheral */ /* Enable Timer 2 peripheral */
@ -142,6 +143,14 @@ void LEDtoggleOnTimer2underflow()
TIM2->DIER |= TIM_DIER_UIE; TIM2->DIER |= TIM_DIER_UIE;
/* Start Timer */ /* Start Timer */
TIM2->CR1 |= TIM_CR1_CEN; TIM2->CR1 |= TIM_CR1_CEN;
#endif
timerInitCounter(timer_2,(8E6/20E3)-1,10000-1,upCounting);
//TIM2->EGR = TIM_EGR_UG;
TIM2->DIER = TIM_DIER_UIE;
timerSart(timer_2);
NVIC_SetPriority(TIM2_IRQn, 2); NVIC_SetPriority(TIM2_IRQn, 2);
NVIC_EnableIRQ(TIM2_IRQn); NVIC_EnableIRQ(TIM2_IRQn);

Loading…
Cancel
Save