Hi. I'm in the process of converting on of my projects from a PIC16F18323 to a PIC24FJ64GA705 and some functionality seems to have dropped out. Whereas for the PIC16F I could control the sleep period like so...
...for the PIC24FJ the config bits that control the WDT period are not accessible during run-time.
Is there a way to achieve sleep (for power saving purposes) for a desired period in the PIC24FJ family? I could use the config bits to set the WDT period to 1sec and sleep in a loop multiple times but this seems like a fudge and I expect there's a better way to do what I want.
Code:
if(armStage==INIT)
WDTCONbits.WDTPS = 0b10000; // if we've just turned on the MOTIONMODULE, sleep for 1 minute
else if(isAlerting)
WDTCONbits.WDTPS = 0b01000; // try again quickly
else
WDTCONbits.WDTPS = 0b01100; // 4s: short period
WDTCONbits.SWDTEN = 1; // enable
SLEEP();
WDTCONbits.SWDTEN = 0; // disable
Code:
FWDTbits.WDTPS = 0x9; // 2^9 * 4ms = 2 secs
C:/Users/Robin/MPLABXProjects/SensorSirenPIC24F.X/main.c:538:13: error: 'FWDTbits' undeclared (first use in this function)