On Wed, 25 Oct 2006, David wrote: > In addition to requesting help regarding the entering and exit of sleep > mode, will the watchdog time fully timeout (ie. not be reset each time > the micro wakes for INT2) ? The sleep instruction clears the WDT. Waking up will not. > I have set up the code shown below. The aim was to toggle a pin each > time the micro woke up so I can time the watchdog timeout. > What actually happens is the micro sleeps for 4-5 seconds then wakes up > and toggles the pin for several seconds at around 64ms > then sleeps for 4-5 seconds again. The watchdog timer postscaler is set > 1:1 at present. The micro is using internal 4MHz oscillator. If your code wakes up from an interrupt, TO will be set, and the WDT will still be running. You won't get into your "if (!TO)" code, and the PIC will reset when the WDT times out. At that point, TO will be clear, and you'll get back into your "if (!TO)" code until you have another interrupt. > void init() > { > DP1203_init(1,10); > INTERRUPT_init(); > PulseCount = 0; > ADCON1 = 0xff; > OSCCON = 0x60; // 4MHz > IDLEN = false; > SCS0 = false; > SCS1 = false; > SWDTEN = true; > SLEEP(); > } > > void main(void) > { > init(); > for(;;) > { > if(!TO) > { > LATB3 = !LATB3; > //SetRFMode(RF_SW_TRANSMITTER); > //RFPORT.Buf[0] = hi_byte(PulseCount); > //RFPORT.Buf[0] = lo_byte(PulseCount); > //SendRFPacket(0x02,RFPORT.Buf); > //SetRFMode(RF_SW_TRANSMITTER); > IDLEN = false; > SCS0 = false; > SCS1 = false; > SWDTEN = true; > SLEEP(); > } > } > } > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- John W. Temples, III -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist