PDA

View Full Version : Using Sleep command



suded
- 8th April 2005, 02:53
Hello again,
Can I ask once more about Sleep command.
I'm running it OK on 16F84.
When using 18F1220 I get 1/4 of the delay value.
On the 16F84 the delay depends on processor voltage but more or less close.
Usually 12 seconds more for each minute of delay but consistent.
Do I need to set any registers on the 18F1220.
Any one please.

Bruce
- 8th April 2005, 04:16
The PBP default WDT postscaler is set to 128 in the 18F1220.INC device family header file.

__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H

The 18F1220 nominal WDT timeout period is ~4mS. If you accept the default postcaler value of 128 this gives you roughly 4mS * 128 = 512mS. That's why you're seeing roughly 1/4 the sleep period when switching from 16F to 18F.

PBP can't change the WDT postscaler on the 18F since this is set in the config word. To make sleep work roughly the same on the 18F, just set the WDT postscaler to 512 which gives you 512 * ~4mS = ~2.048S nominal WDT timeout period.

Set your WDT postscaler to 512.

__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H

The 16F WDT timeout period is 18mS. PBP sets OPTION_REG for prescaler assignment to WDT with a rate of 128. This gives ~18mS * 128 = 2.304S.

With _WDTPS_512_2H this will get you pretty close to the same sleep time periods with the 18F part. If you need to increase this time period, just increase the postscaler.