Skip to main content
Graduate
December 27, 2023
Solved

Timer interrupts

  • December 27, 2023
  • 4 replies
  • 2309 views

Hi
I have a problem with the right priority setting, although I am not sure.
The genelranie timer worked for me and refreshed the LCD screen every 375ms, but when I added interrupts for the ADC (needs to handle a potentiometer) then suddenly the TIM6 stopped working. Debugging the code I noticed that after going through this instruction:
HAL_TIM_Base_Start_IT(&htim6);
terminates the program, it just doesn't continue. This can be seen in the posted screenshots.
Do you have any ideas? I also tried using DMA and unfortunately the effect was the same :(

1_debug.png

 

2_conf.png

    This topic has been closed for replies.
    Best answer by TDK

    It's stuck in the ADC handler, so either the ADC is triggering too often (most likely) or there is some flag not being cleared by the handler (less likely).

    Reduce your ADC trigger frequency to, say, max 10 kHz.

    4 replies

    Super User
    December 27, 2023

    Hit pause, see where execution is at. Probably you are swamped with interrupt requests, or your interrupt handler is stalling. Could be due to ADC being triggered repeatedly.

    grzeniuxAuthor
    Graduate
    December 27, 2023

    It stopped here. But it doesn't tell me anything. How do I fix it?3.jpg

     

     

     

    EDIT:

    The earlier screen was after small modifications
    Below is consistent with the information contained in the start of the thread

    4.jpg

    TDKAnswer
    Super User
    December 27, 2023

    It's stuck in the ADC handler, so either the ADC is triggering too often (most likely) or there is some flag not being cleared by the handler (less likely).

    Reduce your ADC trigger frequency to, say, max 10 kHz.

    grzeniuxAuthor
    Graduate
    December 27, 2023

    Ok it worked after setting the Timer to 10kHz - the code moved on
    BUT
    now the ADC doesn't work, did I set everything right?

    When doing the ADC I suggested this article: https://controllerstech.com/stm32-adc-single-channel/

     

    5.png6.jpg

    grzeniuxAuthor
    Graduate
    December 27, 2023

    Could someone please check?