Quote Originally Posted by pedja089 View Post
If you look into .lst file you can find label called NAP.
Here is copy/paste of code that deal with WDTCON
Code:
movwf   FSR0H           ; Save period somewhere for a moment
movlb   WDTCON >> 7     ; Point to bank
movf    WDTCON, W       ; Save current WDTCON value
movwf   FSR0L
lslf    FSR0H, W        ; Get saved period and rotate it into position
iorlw   1               ; Set software WDT on
movwf   WDTCON          ; Set WDTCON
sleep                   ; Enter sleep mode
movf    FSR0L, W        ; Reset WDTCON to saved value
movwf   WDTCON
So every time you go to nap, PBP set SWDTEN, nap for while, and then restore value that was before going to nap.
IF you_wait_for_IOC THEN
WDTCON.0=0 'Disable WDT
@ Sleep
Else
Nap 1
ENDIF
thank you!
one thing (at least ) confuses me about your reply
you say "PBP set SWDTEN"
but that can only be done in CONFIG1, correct ?
is your example compatible with 16F1933 or is it 18F ?

here is from my LST file
00C6 0085 06483 NAP movwf FSR0H ; Save period somewhere for a moment
00C7 0021 06484 movlb WDTCON >> 7 ; Point to bank
00C8 0817 06485 movf WDTCON, W ; Save current WDTCON value
00C9 0084 06486 movwf FSR0L
00CA 3505 06487 lslf FSR0H, W ; Get saved period and rotate it into position
00CB 3801 06488 iorlw 1 ; Set software WDT on
00CC 0097 06489 movwf WDTCON ; Set WDTCON
00CD 0063 06490 sleep ; Enter sleep mode
00CE 0804 06491 movf FSR0L, W ; Reset WDTCON to saved value
00CF 0097 06492 movwf WDTCON
00D0 2926 06493 goto DONE ; Done
06514 LIST

i will play with what i have learned here and back to you, thanks again