Hello buddies, worry for disturbing but I almost died in attempts to run software resset when my program freezes. Rly need som1s help. I know exatcly moment when my programm has to be reseted, But I dunno how could I do it. I read the documentation about watchdog, but couldnt find out how to implement it. So, maybe som1 could help me with the example of software reset function or watchdog srst example. God bless u all )))
On XC161 I use _trap_(0) for a software reset. It may be similar.same on XC167
In fact, I do this so that I can catch the fault in the debugger and examine the TFR register
void Class_B_trap (void) interrupt irq=CACHED // 0x0A { /* TFR Bit Conditions * TFR.0 = Illegal External Bus Access (no external BUS defined for address) * TFR.1 = Illegal Instruction Access (branch to odd address) * TFR.2 = Illegal Word Operand Access (word read/write on odd address) * TFR.3 = Protection Fault (protected instruction with illegal format) * TFR.4 = Illegal or erroneous access to program memory interface * TFR.7 = Undefined Opcode (invalid 166/167 op-code) * TFR.12 = Software break event * TFR.13 = Stack Underflow * TFR.14 = Stack Overflow * TFR.15 = Non Maskable Interrupt */ PSW_IEN = 0; // Disable interrupts ip = _pop_ (); csp = _pop_ (); pc2 = _pop_ (); pc1 = _pop_ (); tfr = TFR; for ( ;; ) ; _trap_(0); // Reset CPU }
Regards Paul