Back when i took machines apart for a living ,sometimes the SW saved FE's an error tally... device,code count etc was very useful, I tried to do same in my amateurish way, with a PIC24 development board using the watchdog timer, eventually it sort of worked but didn't peruse it as reporting tallies is difficult using one, or even 4 leds...
takes up IO as well... this is something of what I had...
Not all C code !
( ETO code tab not working ?)
#define _trapISR __attribute__((interrupt,no_auto_psv))
unsigned int WD_err __attribute__ ((persistent)) ;
unsigned int Err_dev __attribute__ ((persistent)) ;
Note.. This line sprinkled in main loop !
asm("CLRWDT"); // clear the 2 sec WDT
Note... one of the possible dead end routines
void HIH_read() // read humidity and temp sensor
{
WD_err=0x0028;
Err_dev=0x0027;
unsigned int raw_data= 0 ;
unsigned int HIH_data[4];
unsigned int x;
I2C_start_W(HIHaddr); // wake up HIH6030 HIHaddr 0x0027
I2C_endtx();
DLYm(50); // read delay
I2C_start_R(HIHaddr); // starts read HIH6030
for(x=0;x<3;x++)
…................