Problem with TIM1 overflow interrupt for STM32G0
Hello,
I'm studing timer, and I wanna raise an interrupt every second using the Timer1.
I write this code in main:
rcc->APBENR2 |= RCC_APBENR2_TIM1EN_Msk; //Enable Timer1 clock
timer->CNT = 0;
timer->ARR = 1000;// up to 1000
timer->PSC |= 16000 - 1;//actual MPU frequency: 16MHz
timer->EGR |= TIM_EGR_UG_Msk;
timer->DIER |= TIM_DIER_UIE_Msk;//Enable Timer1 interrupt
NVIC_SetPriority(TIM1_BRK_UP_TRG_COM_IRQn , 0x01);
NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
timer->CR1 |= TIM_CR1_ARPE_Msk | TIM_CR1_CEN_Msk;
And this IRQ handler:
void TIM1_IRQHandler(void)
{
printf("INT\r\n");
if (TIM1->SR & TIM_SR_UIF)
{
printf("INT\r\n");
TIM1->SR &= ~TIM_SR_UIF; // Pulisci il flag di overflow
}
}
The problem is that my code stuck in NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
I have no information also in debug...
Could you help me with this interrupt?
Thanks a lot!
