2021-02-16 01:05 AM
HI, i am using two timers in interrupt mode by setting 100khz frequency for each . one timer interrupt is for my power factor calculation and other one for current calculation. But the problem is when it comes to while loop. once my code enter into interrrupt functions works fine after coming out of the interrupt it is not entering while loop . and the logic inside the while loop is also not executing. can anyone help me with it please . why i am not able to enter and execute while loop.
Thank you
2021-02-16 01:19 AM
The interrupts are quite frequent @100kHz. Maybe there is no time for the main loop left because one interupot is always pending? Lower the freq. for testing.
2021-02-16 08:56 PM
Even if i lower the frequency in one timer to 1khz and other timer as usual 100khz . still its not going to while loop and even it is affecting the other timer which i set to 100khz . can you help me what is the problem in my logic.
Thank you
2021-02-16 10:32 PM
We cannot see your code.
I suggest to add code lines that toggle a GPIOs at the entry and exit of the invovled interrupt routines, and watch them with a scope.
Supposedly, your interrupts overrun their time slot, at least occasionally. That should show on the scope.
2021-02-17 01:11 AM
Thank you
2021-02-17 01:38 AM
even i checked in scope waveforms are generating for both timers. Actually my timer and while is working only once after it will be stopped. Again it is not repeating . i have attached my code below please help me what i have done wrong and what i need to add it.
Thank you
2021-02-17 03:35 AM
As it seems, you do floating point operations inside the interrupt handler, and LCD operations. Callbacks run in interrupt context.
That looks deadly.
The fp routines might cause no runtime problem on M4 MCUs, but have an impact on stack handling.
See e.g. here:https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/10-useful-tips-to-using-the-floating-point-unit-on-the-arm-cortex--m4-processor
I suppose your LCD operations will overrun the time budget by an order of magnitude.
Such things are not done in interrupt context.
2021-02-17 07:58 PM
Thank you
2021-02-18 01:07 AM
The code is working fine now. Thanks for helping me . But it is not running continuously instead after running few minutes it shows HardFault error like this. I have attached the photo below . Please help me what is the wrong in my code and how to solve it.
Thank you
2021-02-18 02:23 AM
The code is working fine now. Thanks for helping me . But it is not running continuously instead after running few minutes it shows HardFault error like this. I have attached the photo below . Please help me what is the wrong in my code and how to solve it.
Thank you