This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Watchdog trouble on 87C51 using PCA

Hi,

I'm trying to use the watchdog on an 87C51. I've set up the PCA module 4 and it works when using timer 0 or the external pin (P1.2) to clock the main PCA timer, but when I select the internal clock to run the main timer, the watchdog activates whenever I start the main PCA timer. Sample code below:

CL = 0;         // reset main PCA count
CH = 0;
CCAP4L = 0xFF;  // set highest match count
CCAP4H = 0xFF;
CCAPM4 = 0x48;  // set compare and match
CMOD = 0x40;    // enable watchdog
CCON |= 0x40;   // startup PCA timer

When I run the last line, the watchdog resets immediately. If I change the initialization order and start the PCA timer first before enabling the watchdog, I can see that CCON reads as '0xF0', meaning that module 4 has already found a match. At that point I cannot clear those interrupt bits from CCON, even if I write a '0x40' again to it, it still reads '0xF0'. So then when the PCA counter is started, the processor is reset immediatley without getting to the next opcode.

Thanks anybody who has an idea about this!

Jeff

0