I seem to have reached the limits of my diagnostic ability with my latest sketch. I can get individual functions to work, but some combination of my code is causing it to lock up as soon as I call radio.write from the RF24 libraries.
The issue does not appear to be hardware, as loading another sketch which does nothing other than prepare the payload package and send it, works fine.
The purpose of my sketch is to be reading IR data and LED pulses from an energy meter, and then transmit the measurements via RF. The measurements are achieved through the use of two ISRs, as the timing is obviously critical.
My suspicions are that this lockup has something to do with the radio functions being interrupted by ISRs, however surrounding the radio functions with noInterrupts() does not seem to help. The other possibility is that my RTC module is wired to the SDA/SCL pins of the Arduino Uno, but I confess my unerstanding of I2C is poor.
And here's something even stranger: If I comment-out the 'radio.write' line but leave 'radio.powerUp' line, the 'checktimes' function runs only once, yet the onPulse ISR continues to execute.
If I disable both radio.write and radio.powerUp, the whole sketch runs correctly, except for the fact that I'm not transmitting my data!!!
If anyone has any ideas regarding what could be causing the lock up, I'd appreciate the help!
No, unfortunately it happens regardless. I'm aware that using Serial prints during ISRs is bad practice, that line is only there during 'debugmode == true' to help me diagnose denouncing issues.
To rule out the debugmode related code I've put a single 'hello world' in the checktimes function, and have been running the sketch with debugmode==false. I still get lockups as soon as the radio related functions are invoked.
After several hours chasing dead ends, I resorted to the most rudimentary method of debugging, by blocking out portions of my code until there was nothing left but the RF related functions. I still couldn't get it to work, so I copied each piece into a new sketch and compared it to my original RF sending sketch.
No, unfortunately it happens regardless. I'm aware that using Serial prints during ISRs is bad practice, that line is only there during 'debugmode == true' to help me diagnose denouncing issues.
Do you know WHY it is bad practice? Can you see that you are more likely to get away with writing "E1" than "Erroneous reading!!"?