2013-04-14 03:25 AM
Hello all,
I've run into the following problem with the program execution. On the STM32f4 Discovery board I've configured two timers with the IRQ routines for measuring two external PWM signals. This works excellently...but... In the main function (within the while block) I need to make some other things (e.g. reading LIS302DL accelerometer values) but only IRQ routines are executed and the while block takes place only after the PWM signal interruption. If PWM signal is not present, the accelerometer values are read well. What can I do to execute all main function and to measure the PWM in the same time? Have I to create another timer with interrupt routine for execution other parts of code? Thank you for your answers in advance. #interrupt #timer2013-04-14 05:51 AM
The processor can only execute one thread at a time, if you spend too much time in the interrupt routine, loop endlessly, fail to leave, or fail to clear the interrupt, then the foreground loop will never execute.
Your description is all well and good, but the code for the interrupt routines would more illustrative.2013-04-14 06:31 AM
2013-04-14 06:37 AM
Oh, maybe you'll ask for what the ''distance = DutyCycle;'' command is...
It is prepared for performing another calculation there that is not implemented yet.2013-04-14 06:39 AM
You would definitely want to get the sprintf and USART stuff out of the interrupt handler.
You could buffer USART output, and then deal with it a character at a time in a USART interrupt handler. The microprocessor is capable of doing the things you want, but the resources are finite and if you saturate them doing one thing they won't be available for others.2013-04-14 06:52 AM
2013-04-14 07:44 AM
I am beginner in ARM SW development...
Having streamlined IRQ handlers is not an ARM issue. A routine that expects to service a periodic interrupt at 1 ms (1 KHz) can't take more than 1 ms to run.2013-04-22 07:36 AM
Thank you very much, Clive!
I did what you recomend and now everything works like a charm! Jirka