SWDTEN is bit 0 of WDTCON register.
When using nap iorlw 1 and movwf WDTCON enables SWDTEN bit before sleep.
And WDTCON is restored after sleep.
SWDTEN is bit 0 of WDTCON register.
When using nap iorlw 1 and movwf WDTCON enables SWDTEN bit before sleep.
And WDTCON is restored after sleep.
correct, SWDTEN is bit 0 of WDTCON, my usage of the term was not clear as SWDTEN is also the name one of the config settings for WDT, sorry about that
the way i read everything in the data unless config1 <4:3> is set to allow SWDTEN then SWDTEN bit in WDTCON.0 is ignored
this is from the data sheet for WDTCON
WDTE is 2 bits in CONFIG1
bit 0 SWDTEN: Software Enable/Disable for Watchdog Timer bit
If WDTE<1:0> = 00:
This bit is ignored.
If WDTE<1:0> = 01:
1 = WDT is turned on
0 = WDT is turned off
If WDTE<1:0> = 1x:
This bit is ignored.
this is what i cannot get to work correctly, have tried many things
i can turn WDT hard ON or hard OFF in config and things work as expected, but when i set WDT to SWDTEN in config the SWDTEN bit of WDTCON does not work correctly,
have tried setting it manually in parts of test code before and after NAP
i can see the WDTCON.0 being of the expected state but WDT is not turning ON and OFF following the bit
i think maybe NAP is not handling this chip correctly or maybe there is a bug in chip ?
thanks for your patience in following up on this, maybe i have missed something you have said ?
looking at the NAP ASM code it does not seem to know about the WDT config settings ? is that true ?
It doesn't know... But relays on you to set WDT ON or to set WDT CONFIG to software control. If it is always on, then setting bit 0 doesn't have effect.
If you set WDT to softvare control NAP will work as expected. It ALWAYS ENABLE WDT in WDTCON and wake up after while. If you disable WDT in CONFIG1, NAP stil enables bit 0 in WDTCON but it doesnt have effect. WDT will stay off and never wake up device.
To wait for IOC, disable WDT in WDTCON, by reseting bit 0, and then use @ sleep to put device into low power mode.
To wake up pic after while just use nap.
I alredy wrote that at end of post #3.
Last edited by pedja089; - 28th September 2014 at 20:55.
I am off this project for a short while, but i will be back on it in a week or so and follow up as this topic interests me
in the meanwhile i have done a workaround by setting CONFIG to WDT ON, then when it falls out of NAP i check IOC flag and i can tell if it timed out or got interrupted and act accordingly
this burns a tiny bit more power than i had wanted (as it wakes up periodically) but i have big battery and i think it will be insignificant compared to self discharge
pedja089, i will try your @ sleep suggestion when i start project again
Bookmarks