View previous topic :: View next topic |
Author |
Message |
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
Fuses - Major Gotcha |
Posted: Mon Jun 25, 2007 12:56 pm |
|
|
I just had a production run of devices built and shipped out. I'm finding out now, the assembly company over rode my fuse settings. I do have a loader on board for software changes, but it doesn't allow fuses settings to be messed with.
Here is what I have. 18F2580 -20
In my code I had. #FUSES HS,NOWDT,NOLVP
The assembly company turned on the WDT, changed the WDT Post Scaler, and the Port B reset State.
Now my device does nothing but constantly reboot. Field personel can flash it with the loader software but have no way to hardware program the devices. It's a lot of devices and this not exist in the prototype I approved.
My question, is the reason it's rebooting is because the WDT is turned on on the chip, but not in the software? Could I turn it on in the software app. then reflash the systems. Would this keep it reset?
Any way to burn fuses without a hardware programmer?
Help, in a bind.
Richard |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 1:14 pm |
|
|
If I'm lucky, should I be able to sprinkle a few reset_wdt(); in my code and fix it. Seems to work, any side affects? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 25, 2007 1:49 pm |
|
|
I'd make the assembly house re-do it. Remove the PIC chips,
re-program them, and re-install them.
In the future, put the pads on the board for a 6-pin header
(1x6, 0.100 inch spacing), and connect it to the PIC so you can
do ICSP programming. We do all our boards this way. |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Mon Jun 25, 2007 1:52 pm |
|
|
to turn on the WDT for pic18 use the command:
setup_wdt(WDT_ON);
to turn off the WDT for pic18 use the command:
setup_wdt(WDT_OFF);
I'm guessing that you want to put that around a block of code you want to check if it hangs. That is how I do it. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 1:54 pm |
|
|
I have headers on the board. I'm sure I could push the issue and have them re-do it. Thing is, these are now in distribution. Much easier to do a software fix and send out a new flash file, if possible. If I had all the time in the world, and I wanted to make a point, I would have each one sent back under warranty, however time is not at my leisure right now. Also, they are totally enclosed and sealed, a real pain to take that many apart to flash. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 1:57 pm |
|
|
grasspuddle wrote: | to turn on the WDT for pic18 use the command:
setup_wdt(WDT_ON);
to turn off the WDT for pic18 use the command:
setup_wdt(WDT_OFF);
I'm guessing that you want to put that around a block of code you want to check if it hangs. That is how I do it. |
Okay, but doesn't that simply burn a fuse when hardware programming the chip? Systems are already programmed and sent out. All I can do is have them all returned, take them apart, reflash OR send out a software patch they can load with the loader program via RS232.
What I'm saying is, I can't change the fuses via the loader, but since the fuse is already burned, I can modify my code to reset the WDT in my loop. |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Mon Jun 25, 2007 2:27 pm |
|
|
Quote: | I can modify my code to reset the WDT in my loop. |
What's wrong with the watchdog? I use it almost in all my code.
So look at the bright side of life: you are forced to use a good programming practice. I suggest to not just sprinkle the the code with reset_wdt()s but to use the watchdog as it is supposed to be: to monitor the reliability of your code detecting (and correcting) hang-ups. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 2:42 pm |
|
|
libor wrote: | Quote: | I can modify my code to reset the WDT in my loop. |
What's wrong with the watchdog? I use it almost in all my code.
So look at the bright side of life: you are forced to use a good programming practice. I suggest to not just sprinkle the the code with reset_wdt()s but to use the watchdog as it is supposed to be: to monitor the reliability of your code detecting (and correcting) hang-ups. |
There is nothing wrong with the watchdog. Problem is, "I" did not set it up. so I'm not sure what time it's set to. I'm doing RS232, RS485 Modbus, and Doing J1939 CAN. Lots of stuff going on. When I started this project, a couple of folks here recommended to turn the WDT off since I was doing all this communication and interrupts.
The watchdog post timer prescaler is set to 1:512 and I'm running at 20mhz. I'll try to figure it but the Datasheet is mostly greek. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 3:02 pm |
|
|
libor wrote: | Quote: | I can modify my code to reset the WDT in my loop. |
What's wrong with the watchdog? I use it almost in all my code.
|
Let's see, on the 18F2580, it states the wdt can be from 4ms to 131.072 seconds. So if I have a postscaler value of 1:512 that means my time is set to 0.004 x 512 = 2.048 seconds correct? |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Mon Jun 25, 2007 3:03 pm |
|
|
if the postscaler is set to 1:512, this results a 4ms x 512 = 2048 msec = ~2s timeout. Must be enough time to reset it. (...much better than if it was set to 4ms) |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Mon Jun 25, 2007 3:05 pm |
|
|
libor wrote: | if the postscaler is set to 1:512, this results a 4ms x 512 = 2048 msec = ~2s timeout. Must be enough time to reset it. (...much better than if it was set to 4ms) |
Cool, that is what I came up with as well. Whew, that makes life much easier.
Thanks! |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Tue Jun 26, 2007 6:33 am |
|
|
what do you want the fuse changed to? if it is to turn the watchdog timer off completely then just turn off the watchdog in the beginning of your code
( setup_wdt(WDT_OFF); ) |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Tue Jun 26, 2007 6:43 am |
|
|
grasspuddle wrote: | what do you want the fuse changed to? if it is to turn the watchdog timer off completely then just turn off the watchdog in the beginning of your code
( setup_wdt(WDT_OFF); ) |
OK, Let me ask a basic question here. Am I mistaken, that the WDT and postscaler are fuses, that can not be changed later, unless changed with a HW programmer?
In otherwords, if the "fuse" is burned a programming time, your software can't override the WDT at runtime can it?
If the chip is burned with the WDT_OFF fuse setting, then in your code, setting up the WDT and calling reset_wdt() does nothing correct? |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Tue Jun 26, 2007 6:59 am |
|
|
Look at pages 352 and 353 of the data sheet
There are two bits that control whether the WDT is on or off, one is a fuse WDTEN and the other is a bit in the WTCON register SWDTEN.
see the note for the SWDTEN bit
Quote: |
Note 1: This bit has no effect if the Configuration bit, WDTEN, is enabled. |
I your case, since the fuse is turned on you cannot turn off the WDT through software. |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Tue Jun 26, 2007 7:25 am |
|
|
I've just checked when the WDT was off, never thought that it would be different when it was on by fuses, my bad
Also since i'm a masochist:
Register 24-14 shows the WDTCON register. This is a
readable and writable register which contains a control
bit that allows software to override the WDT enable
Configuration bit, but only if the Configuration bit has
disabled the WDT.
So software can't save you by turning it off... |
|
|
|