Thanks for the tip. I'll rethink some things. I'm trying to bit-bang 24 individual port pins(channels), sometimes they overlap or occur right next to each other . It's not that I'm trying to generate long periods, I'm trying to use a cheap method to figure out what events are next and which ones may be late. All of that works decently but requires me to handle the overflow interrupt in xgate, which as I stated created a new problem in my S12 IC ISR. Let me see if your suggestions sparks some new ideas.
On a different note, making those mutex changes did not fix the problem. Here is what almost works(1000x less bogus input capture stamps), but I'm not sure why.
| do { |
| XGSEM = 0x0202; |
| } while (!(XGSEM & BIT1)); |
| if(((timerExtensionClock != timerExtensionClockShared) && !(edgeTimeStamp & 0x8000))) { |
| timeStamp.timeShorts[0] = timerExtensionClock + 1; |
| }else{ |
timeStamp.timeShorts[0] = timerExtensionClock;
}
| XGSEM = 0x0200; //Clear semaphore 1 by writing mask=1 and flag=0 |
timerExtensionClock, is not a shared variable, it gets updated in an S12 RTI interrupt that runs every 10uS. Why does this work so much better, but not 100% of the time?
void RTIISR(){
/* Clear the RTI flag */
CRGFLG = 0x80;
do {
XGSEM = 0x0202;
} while (!(XGSEM & BIT1));
if (timerExtensionClock != timerExtensionClockShared) {
metronome();
}
XGSEM = 0x0200; //Clear semaphore 1 by writing mask=1 and flag=0
///metronome()
do {
XGSEM = 0x0202;
} while (!(XGSEM & BIT1));
timerExtensionClock = timerExtensionClockShared; // bring s12 timer extension up to date
XGSEM = 0x0200; //Clear semaphore 1 by writing mask=1 and flag=0
Thanks
http://powerefi.com/files/operation.txt