[STM32F103RB] Timer 1 interrupt doesn't execute

Thread Starter

Tadzik

Joined Jan 22, 2017
5
In main():
Code:
    TIM_TimeBaseStructInit(&tim3);
    tim3.TIM_Period = 10 - 1;
    tim3.TIM_Prescaler = 64 - 1;
    tim3.TIM_ClockDivision = 0;
    tim3.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM1, &tim3);
    TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
    TIM_Cmd(TIM1, ENABLE);

    nvic.NVIC_IRQChannel = TIM1_UP_IRQn;
    nvic.NVIC_IRQChannelPreemptionPriority = 0;
    nvic.NVIC_IRQChannelSubPriority = 0;
    nvic.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvic);
Interrupt:
Code:
void TIM1_UP_IRQHandler()
{
    if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET)
    {
        send_char('k');
    }
}
Doesn't matter what send_char is doing - it's never executed, and breakpoints placed in interrupt never hit.

And here I have another timer with interrupt, it's almost the same, except this one works:

In main():
Code:
    TIM_TimeBaseStructInit(&tim2);
    tim2.TIM_CounterMode = TIM_CounterMode_Up;
    tim2.TIM_Prescaler = 64000 - 1;
    tim2.TIM_Period = 100;
    TIM_TimeBaseInit(TIM3, &tim2);
    TIM_Cmd(TIM3, ENABLE);

    nvic.NVIC_IRQChannel = TIM3_IRQn;
    nvic.NVIC_IRQChannelPreemptionPriority = 0;
    nvic.NVIC_IRQChannelSubPriority = 0;
    nvic.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvic);
Interrupt:
Code:
void TIM3_IRQHandler() {
    if (TIM_GetITStatus(TIM3, TIM_IT_Update) == SET) {
        TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
        pwm(0);
        TIM_ITConfig(TIM3, TIM_IT_Update, DISABLE);
        send_char('t');
        flag = 1;
    }
}
Is there some conflict, when you can't use timer 1 with something other? Because I know when I try to use timer 2, then USART doesn't work.
 
Top