Content originally posted in LPCWare by dragilla on Wed Nov 16 03:59:52 MST 2011
Hello,
I am quite new to the uP programing so I need some help to understand some things.
Perhaps you help me me out.
I have the following, theoretical situation:
1) 1 main loop, working with constant frequency, say 100hz (so every 10ms). One loop cycle takes about 5ms, so theretically there is 5ms free processor time every cycle
2) I have a function that is triggerred by am external interrupt. This function is very simple and fast, takes lot less processor time that the main loop
I want the interrupt function to always react in an instant manner, that is : it is triggered and the ouput of it is always set with a predictable delay.
But what I also need is that the loop cycle always occurs regularly, because I'm doing some time based calculations there.
Is it even possible to do? I guess it's not because if I want the interrupt function to have priority, then when an interrupt comes in the middle of the loop cycle then the loop cycle is paused to service the interrupt. Is this right?
If so, then maybe another approach is possible, namely maybe I can read the timestamp in the loop function and based on that timestamp I can do my calculations?
Let me know if you understand what I mean and what you think about it.
cheers,
--
Luke