solved some mistakes... not yet working!

redesign_interrupts
polymurph 3 years ago
parent 03801bd5e6
commit d2af5b6a4b

@ -12,7 +12,7 @@
volatile uint8_t led_on; volatile uint8_t led_on;
void setup(); void setup();
#if 0
void EXTI0_1_IRQHandler(void) void EXTI0_1_IRQHandler(void)
{ {
if(EXTI->PR & EXTI_PR_PIF1) { if(EXTI->PR & EXTI_PR_PIF1) {
@ -52,7 +52,7 @@ void risingEdgeInterruptPinA1()
} }
} }
} }
#endif
void interruptLEDtoggleOnTIM1counterCompare() void interruptLEDtoggleOnTIM1counterCompare()
{ {
//timerInitCounter(timer_2, 0xFFFF, 0, upCounting); //timerInitCounter(timer_2, 0xFFFF, 0, upCounting);
@ -60,6 +60,8 @@ void interruptLEDtoggleOnTIM1counterCompare()
// reset timer 2 periperal // reset timer 2 periperal
RCC->APB1RSTR |= RCC_APB1RSTR_TIM2RST; RCC->APB1RSTR |= RCC_APB1RSTR_TIM2RST;
//while(RCC->APB1RSTR & RCC_APB1RSTR_TIM2RST);
// enable timer 2 peripheral // enable timer 2 peripheral
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
@ -69,6 +71,8 @@ void interruptLEDtoggleOnTIM1counterCompare()
// only allow under-/overflow interrupts // only allow under-/overflow interrupts
TIM2->CR1 |= TIM_CR1_URS; TIM2->CR1 |= TIM_CR1_URS;
TIM2->CR1 |= TIM_CR1_DIR;
// set clock prescaler // set clock prescaler
TIM2->PSC = 0xFFFF; TIM2->PSC = 0xFFFF;
@ -84,6 +88,7 @@ void interruptLEDtoggleOnTIM1counterCompare()
NVIC_SetPriority(TIM2_IRQn,0); NVIC_SetPriority(TIM2_IRQn,0);
NVIC_EnableIRQ(TIM2_IRQn); NVIC_EnableIRQ(TIM2_IRQn);
// timer enable
TIM2->CR1 |= TIM_CR1_CEN; TIM2->CR1 |= TIM_CR1_CEN;
//timerSart(timer_2); //timerSart(timer_2);
@ -103,8 +108,10 @@ void interruptLEDtoggleOnTIM1counterCompare()
void TIM2_IRQHandler(void) void TIM2_IRQHandler(void)
{ {
if(TIM2->SR & TIM_SR_UIF) { if(TIM2->SR & TIM_SR_UIF) {
// clear flag // clear flag
TIM2->SR &= ~TIM_SR_UIF; TIM2->SR &= ~TIM_SR_UIF;
//pinWrite(pinB3,1); //pinWrite(pinB3,1);
pinToggle(pinB3); pinToggle(pinB3);
} }
@ -115,7 +122,6 @@ int main(int argc, char *argv[])
{ {
setup(); setup();
//risingEdgeInterruptPinA1();
interruptLEDtoggleOnTIM1counterCompare(); interruptLEDtoggleOnTIM1counterCompare();
while(1); while(1);

Loading…
Cancel
Save