Mr RB
Well-Known Member
Hi, this little problem has me pulling hair out and I can't work out why! 
I have a PIC 18F2420 running on 8MHz xtal HS mode, and it needs to be a low power app that sleeps most of the time and wakes up on the WDT timeout, performs a few mS of code, and back to sleep.
The test code for the moment is literally as simple as this;
The result on the 'scope looks like this;
1. LED on for 20mS, 2.5mA
2. SLEEP for 272mS, approx 0mA
3. Powers up, 2.0mA, for 272mS, before code execution starts
(The 272mS period is the correct WDT period for the WDT /64 setting in the config.)
It should do this;
1. LED on for 20mS, 2.5mA
2. SLEEP for 272mS, approx 0mA
So, apparently after osc powers up it is stuck for ANOTHER WDT timeout period, before code execution starts! This is terrible as I need it to sleep for a WDT for about 10 seconds, then be awake for a couple mS.
Testing everything I can think of showed both the periods match, and both are the WDT timeout period.
I have messed with the majority of the settings, FSCM, 2speed startup, PWRT on/off etc and it does not matter what settings are used, there is always a delay of 1 WDT timeout after power up and BEFORE code execution starts! As you can understand this is killing my low power application as the best power reduction I can get is 50:50 by time (sleep/powered).
Changing osc type does not help, even on the internal osc block the WDT problem is identical.
If anyone has a suggestion (like I have forgotten something really silly) then please speak up!
I have a PIC 18F2420 running on 8MHz xtal HS mode, and it needs to be a low power app that sleeps most of the time and wakes up on the WDT timeout, performs a few mS of code, and back to sleep.
The test code for the moment is literally as simple as this;
Code:
main
{
TRISB = 0; // outputs for test LEDs
LATB.F4 = 1; // test LED on
Delay_mS(20);
LATB.F4 = 0; // test LED off
asm SLEEP; // back to sleep
}
The result on the 'scope looks like this;
1. LED on for 20mS, 2.5mA
2. SLEEP for 272mS, approx 0mA
3. Powers up, 2.0mA, for 272mS, before code execution starts
(The 272mS period is the correct WDT period for the WDT /64 setting in the config.)
It should do this;
1. LED on for 20mS, 2.5mA
2. SLEEP for 272mS, approx 0mA
So, apparently after osc powers up it is stuck for ANOTHER WDT timeout period, before code execution starts! This is terrible as I need it to sleep for a WDT for about 10 seconds, then be awake for a couple mS.
Testing everything I can think of showed both the periods match, and both are the WDT timeout period.
I have messed with the majority of the settings, FSCM, 2speed startup, PWRT on/off etc and it does not matter what settings are used, there is always a delay of 1 WDT timeout after power up and BEFORE code execution starts! As you can understand this is killing my low power application as the best power reduction I can get is 50:50 by time (sleep/powered).
Changing osc type does not help, even on the internal osc block the WDT problem is identical.
If anyone has a suggestion (like I have forgotten something really silly) then please speak up!