View previous topic :: View next topic |
Author |
Message |
Stuart H Guest
|
WDT postscale fuse not setting properly! |
Posted: Thu Aug 18, 2005 3:27 pm |
|
|
Using PCH 3.203 with PIC18F4520, the postscaler is not being set correctly. If I specify WDT1 to WDT128 in the #fuses directive it works properly and the correct ratio is set.
However, specifying WDT256 or greater ( I need to use WDT512 ) results in the postscale being set to 1:32768 in all cases. I have verified (with a test program) that this is indeed the case.
Is there a workaround? I need a WDT timeout of around 2 seconds. The settings that work are too short, and I don't want the PIC to lock up for 2 minutes if a problem occurs...
Blast Microchip and their fiddling. I've had more trouble porting this code from an 18F452 than the original port from a 16F877A!!! |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Thu Aug 18, 2005 3:44 pm |
|
|
Why not set them directly? That's what i do and then I don't have to worry about them being "broken" in the next release...
The WDTPS bits are defined in the datasheet on page 252 and the WDT in section 23.2 (page 258). |
|
|
Stuart H Guest
|
|
Posted: Fri Aug 19, 2005 5:39 am |
|
|
Fixed it.
A couple of hours spent with the datasheet, calculator and chipedit.exe revealed that the entire CONFIG2 setup was suspect. It was affecting the brownout as well, but I didn't notice because it didn't impact on operation.
For the benefit of anyone else who comes across this problem, the WDT postscale can be fixed using chipedit.exe - just do this:
WDT256 to WDT32768: change the mask value from 01E0 to 1E00, and shift the value entry one place left in the same way.
The brownout voltage select is totally screwed. Replace the mask value for each entry with 000C. The value entries should read:
BORV25 = 000C
BORV27 = 0008
BORV42 = 0004
BORV45 = 0000
(the chip datasheet says it should be the other way round - I don't know yet if this is an error in the datasheet or MPLAB. I haven't actually tested this in hardware yet)
The other entries (brownout setting and PUT) are OK. These settings can also be applied to the 18F2520, which has the same errors in the CCS configuration settings.
It's probably been fixed anyway in the later compiler releases. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: WDT postscale fuse not setting properly! |
Posted: Fri Aug 19, 2005 7:45 am |
|
|
Stuart H wrote: | Blast Microchip and their fiddling. I've had more trouble porting this code from an 18F452 than the original port from a 16F877A!!! |
Just curious why you are blasting Microchip when its CCS's code that's bad?? |
|
|
Stuart H Guest
|
|
Posted: Fri Aug 19, 2005 8:15 am |
|
|
Oops. The BORVxx mask should be 0018 not 000C... Must register so I can edit my posts.
Mark - the reason I had a pop at Microchip here was that by the time I posted the original message, I'd wasted half a day trying to work out why the code that ran flawlessly on an 18F452 completely failed on a 4520. I found out why only in the depths of the datasheet - they changed the watchdog timings! (4ms into the postscaler versus the older chips 18ms). Then the CCS problem reared its head - my impulsive thought was "why couldn't they have left the damn thing alone!"
In the cold light of day, of course, I can see the advantages of an extended WDT, so my comment was unreasonable. At least I know one of the issues involved in porting to the new chips now! |
|
|
StuartH
Joined: 19 Aug 2005 Posts: 14 Location: W. Midlands, UK
|
|
Posted: Fri Aug 19, 2005 8:24 am |
|
|
I must have read the CCS supplied values into my earlier post by mistake. The correct BORVxx mask/value settings are:
BORV45 0018 0018
BORV42 0018 0010
BORV27 0018 0008
BORV25 0018 0000 |
|
|
|