I’ve determined that programming is like whack-a-mole(only took me 15 years to figure this out!) Fix one problem, and another one that already works stops working. This is what happened to me yesterday.
My ISR raises a pin when its called, and lowers it when it leaves, giving me a pulse that shows not only when it was called, but also how long it was in the ISR. This is important because if we are doing a normal check for a pulse, we could actually miss an edge-event that occurs when we already inside the ISR. This was happening to me.
After adjusting the timing, I got very solid results. Doing some wierd things like clearing RTCC at the beginning of the ISR, setting RTCC to -40 when I’m processing an edge, and then RETURNINT’ing 80 when I’m processing a HIGH. These changes were absolutely perfect and put me ‘spot on’ (as the british might say) the various cells.
It appears to take the SX about 350 to 450ns to recognize an edge before entering the ISR, which sounds horribly long to me. This may have something to do with the nature of the signal, since it doesn’t fall and stay low, although I would think that Schmitt Trigger action on the pin should help this. Also, my ISR appears to take about 500ns total, which given all the processing is acceptable.
With this, I’m redoing the code AGAIN — because I don’t like the fact that I spend so much time in the ISR. The reason right now that I spend so much time is because the store/shift function and transfer to PC function is all built into a routine that is GOSUB’d from the ISR. This code is in essence in the ISR too. I want to remove that code and put the bulk of it in main. Main is completely empty since all the action starts out with an edge trigger.
Now that troubleshooting the timing just got a lot easier, I’m not afraid to change the whole structure of the program. Basically what happened last night was that the transfer to PC routine just wasn’t working. And don’t ask me why — I haven’t figured it out. Hopefully the new code won’t give me as many problems. The transfer to PC was working just fine, up until I fixed my timing issues. Or so I thought.