CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

WDT postscale fuse not setting properly!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Stuart H
Guest







WDT postscale fuse not setting properly!
PostPosted: Thu Aug 18, 2005 3:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 18, 2005 3:44 pm     Reply with quote

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







PostPosted: Fri Aug 19, 2005 5:39 am     Reply with quote

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

View user's profile Send private message Send e-mail

Re: WDT postscale fuse not setting properly!
PostPosted: Fri Aug 19, 2005 7:45 am     Reply with quote

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







PostPosted: Fri Aug 19, 2005 8:15 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 19, 2005 8:24 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group