cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the use of timer interrupts using HAL library

NNola.1
Associate II

Hi everyone, I am new to using ARM architecture based microcontrollers and I am having a problem with peripherals and APBs (Advance Peripheral bus). Currently I am using the STM32F429 (NUCLEO-144) board, programming it with the help of the HAL library and the STM32CUBEIDE IDE.

The problem is that when I configure timer interrupts to have different time bases I can only use timers that share the same APB, otherwise I can't attend to all interrupts, they seem to block each other.

I am using 5 timers, from 2 to 5 which are General Purpose Timers and according to the reference manual they share the same APB (number 1 in this case).

 It happens that, if I add a timer from another APB2 such as time 9 for example, I can no longer attend to interruptions correctly, I would like to know if you can guide me in solving this problem, which I estimate must be basic, but given my lack of experience it becomes difficult to fix.

I am attaching a file in .txt format that saves the content of the main.c file and some captures of the output signals on the board's pins measured with a logic analyzer.

It happens that if I activate all the interruptions, the timer9 does not make the switching on the output pin, without compiling the other interruptions it switches the pin. I can't understand why that happens. I think that the speed that the logic analyzer registers for the case of the interruption of timer 9 is not correct, but that would be for a future query. I hope it can help me.

I appreciate who can help me, greetings.

Enviar comentarios

Historial

Guardadas

Comunidad

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

It sounds like you're just overloading the CPU. The CPU can only run so many instructions per second. If your timers trigger enough to constantly be in interrupt code, the lower priority ones will never fire. Your main code will also never progress.

Reduce the timer frequency by an order of magnitude and try again.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

It sounds like you're just overloading the CPU. The CPU can only run so many instructions per second. If your timers trigger enough to constantly be in interrupt code, the lower priority ones will never fire. Your main code will also never progress.

Reduce the timer frequency by an order of magnitude and try again.

If you feel a post has answered your question, please click "Accept as Solution".
NNola.1
Associate II

Thanks for responding, it sounds logical and in view of your comment I have the need to ask you if it is possible to trigger the use of the spi peripheral with a timer, because the fact of using more than one timer is simply because the project I am carrying out it needs to perform spi transfers synchronously, it doesn't really require handling interrupts which is apparently what generates the overhead. I mean that buffered data is sent cyclically at a specific frequency.

To use them synchronously, set up one as a master and the others as slaves and clock the slaves with the clock from the master. Or all slaves and use a timer pwm as the clock.
If you feel a post has answered your question, please click "Accept as Solution".
NNola.1
Associate II

Thank you very much TDK, I will find information about that idea. If you have a manual as a suggestion I would appreciate it.

Regards.