I really need some help on this one. Does anybody have a code sample using Watchdog timer?
I read the "Watchdog Timer Operation" datasheet, but it is still not very clear to me.
Here is my piece of code (that works) when I don't use the WDTCON postscaler:If I use SLEEP instead of NAP, I can set up the sleeping time up to more than 18 hours.Code:' Fuses @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT,PROTECT_OFF,WDT_ON,PWRT_ON,MCLR_ON @ DEVICE PIC16F88,BOD_ON,LVP_OFF,CPD_OFF,DEBUG_OFF,CCPMX_OFF '------------------------------------------------------------------------------- ' Register settings OSCCON = %01100000 'Internal RC set to 4MHZ ANSEL = %00000000 'Disable Analogue Inputs OPTION_REG = %00000111 'enable PORTB pullups, prescaler to WDT, rate 1:128 'WDTCON = %00000001 'Prescaler 1:32, WDT ON '------------------------------------------------------------------------------- ' Init LED1 var PORTB.0 '------------------------------------------------------------------------------- ' Program MAIN: toggle LED1 NAP 7 goto main end
It looks as the pre- or postscaler don't affect the sleep period... (?)
I'm completely lost....




Bookmarks