How to set up TIM1 and TIM1 Interrupt using registers
Hi guys,
I have trouble with setting up TIM1, I am already using TIM2 and TIM3 to generate PWM signal and ADC conversion. I need TIM1 to generate and handle interrupt so I can display some messages on LCD.
For some reason, I can't do that. I am basically using the same code as for other timers but this one just won't work.
Here is my current code:
void TIM1_UP_IRQHandler(void){
/*code*/
TIM1 -> SR &= ~TIM_SR_UIF; //Update Interrupt Flag
}
void timerispisa1(void){
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
TIM1->PSC = 799;
TIM1->ARR = 10;
TIM1->CCR1 = 100;
TIM1->CCMR1 &= ~TIM_CCMR1_OC2M;
TIM1->CCMR1 |= (0b110 << TIM_CCMR1_OC2M_Pos);
TIM1->CCER &= ~TIM_CCER_CC2P;
TIM1->CCER |= TIM_CCER_CC2P;
TIM1->CCER |= TIM_CCER_CC1E;
TIM1->CR1 |= TIM_CR1_CEN;
TIM1->DIER |=TIM_DIER_UIE; //Update Interrupt Enable
TIM1 -> SR &= ~TIM_SR_UIF; //Update Interrupt Flag
NVIC_EnableIRQ(TIM1_UP_IRQn); //Interrupt Set-Enable Register
__enable_irq(); //Enable Interrupt
}It seems like no matter what GPIO I select it keeps turning on PB11 very fast like ARR and PSC does not have any effect on it. This very similar setup works for me for other timers so I am very confused.
Does anybody can help me, thank you!
