At that point I found that no matter how I tried to rearrange the interrupt call (ISRRX.bas and OnData() as per example in manual), which was doing simple string concatenation to determine a command, it would randomly crash the ADC part of the battery loop. I tried every kind of save/restore I could think of. Then I read Davids comment "dont use interrupt function for very much" but it was too late. In the end I rewrote the entire software and the host PC software using polling and no interrupt function at all.
I traced the problem to my GetVolts function where I combine ADRESH and and ADRESL from the PIC ADC, then scale into a floating point number.
Code: Select all
ADCReading = ADRESH << 8
ADCReading = ADCReading Or ADRESL
GetVolts = (ADCReading*gain) + zero
The interrupt is a really good valuable feature, is there an easy way to guarantee it can be used without crashing the loop its interrupting? Maybe a list of every single register to save, even if its a long list!?
Advice appreciated!