Variable continuity
Posted: Thu Dec 18, 2008 1:23 am
As some of you may know, I have a scheme in the code which has banks of data such that the interrupts don't cause a short to be made up of two halves of two unrelated shorts.
This is achieved by writing input ADC readings etc into one mem location and then when its time to use them, blocking interrupts, switching the variables and using the latest such that the interrupts can continue to store ADC data into the other bank over top of the old copies.
The same occurs on the output stuff, pulsewidths dwell etc. the interrupts use the old ones until the new ones are swapped in once calced.
There are lots of good reasons to do this and a few to not do it.
What I noticed today is that all the vars that aren't inputs and aren't outputs actually only need one copy. I thought i needed to swap those too, but I can't think why now. Can anyone confirm that there is no need to swap those middle ones?
In the future there may be a need as datalogging could be generated on the xgate. In this situation we would want contiguous sets of data, not randomly changing ones. However we aren't there yet so it shouldnt be coded for now anyway.
Thoughts? Can I safely swap back to a single copy of the middle vars? The only things accessing those are accessory functions which can't run at the same time anyway due to being in the main loop too.
Fred.
This is achieved by writing input ADC readings etc into one mem location and then when its time to use them, blocking interrupts, switching the variables and using the latest such that the interrupts can continue to store ADC data into the other bank over top of the old copies.
The same occurs on the output stuff, pulsewidths dwell etc. the interrupts use the old ones until the new ones are swapped in once calced.
There are lots of good reasons to do this and a few to not do it.
What I noticed today is that all the vars that aren't inputs and aren't outputs actually only need one copy. I thought i needed to swap those too, but I can't think why now. Can anyone confirm that there is no need to swap those middle ones?
In the future there may be a need as datalogging could be generated on the xgate. In this situation we would want contiguous sets of data, not randomly changing ones. However we aren't there yet so it shouldnt be coded for now anyway.
Thoughts? Can I safely swap back to a single copy of the middle vars? The only things accessing those are accessory functions which can't run at the same time anyway due to being in the main loop too.
Fred.