View previous topic :: View next topic |
Author |
Message |
CeeBee Guest
|
Lockup due to config... |
Posted: Tue Jan 08, 2008 5:30 pm |
|
|
I'm having problems with, as far as I can tell, lockups due to config bits that I just cant figure out. I have some code I'm working with, someone elses, running on an 18F458. I have their "correct" version on a read-protected chip and their supposedly correct (but isnt) code in file form.
I've programmed a fresh PIC with the code that, as far as I can see, is written fine (with the possible exception of the config bits). When in place and connected to all of the hardware but one bit (a large valve, which is activated by relays) they both perform identically, even the output pins that control the relays act in the same manner (watched on a two-channel scope).
However when the one I have programmed is connected up to the valve the system locks as the valve begins to be actuated (simple pulses to turn the relays on for 50 ms). The power rail appears to be dragged down to around 2.5v average and oscillating at 100Hz. Naturally the PIC sits there unhappy and needs to be reset. When the "correct" pic is used in the same hardware the power rail droops to maybe 4.8 for a ms and then returns to 5.
I know its a stab in the dark but, since I cannot contact the original author, are there any likely culprits? I tried setting NOBROWNOUT- this cures some other issues and makes me thing the PSU is somewhat borderline, but since an identical (bar code) PIC is happy working reliably, it must be a config setting?
Any ideas welcome! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 08, 2008 5:59 pm |
|
|
Add NOLVP and NOXINST. |
|
|
ceebee Guest
|
|
Posted: Tue Jan 08, 2008 6:12 pm |
|
|
Nope :( NOLVP makes no odds and NOXINST is not valid on the 18F458 :(
I'll keep hacking, hoping more ideas flow. Cheers for your input! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
CeeBee Guest
|
|
Posted: Tue Jan 08, 2008 9:14 pm |
|
|
It has protection diodes in place and functions normally with the other PIC so I'm 99% sure its not hardware related. I'm going to go back through the code and check the relay activation routines for stupid mistakes! Its 3am here, no useful work gets done at this time so im off to bed! Thanks for the help! |
|
|
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Wed Jan 09, 2008 12:47 pm |
|
|
I would agree, your 'visible' code must be doing something naughty with your load, that is in turn pulling the supply down - and your 'read only' version isnt doing that. Have you compared all the relevant hardware outputs between the 2 versions? |
|
|
CeeBee Guest
|
|
Posted: Wed Jan 09, 2008 1:29 pm |
|
|
Yes, I've scoped all outputs and they all fire with the same timings. This is why I find it so odd. What I wonder is whether the "visible" PIC is, for some reason, more sensitive to the droop in the power rail. I would have thought the brownout would have caught this and reset it though? I'm going to start by backing up the 5v rail with a 220uF cap to see if thats the problem. The PSU for the whole unit is fairly low current and if the visible code is being naughty but not illegal, it may be tipping it over the edge. Grrr. |
|
|
CeeBee Guest
|
|
Posted: Wed Jan 09, 2008 4:16 pm |
|
|
I think I've found the issue. The relay-switched device is actually a coil tiny. With the original chip (appears to be a C0 revision) the noise produced by the back emf doesnt effect the PIC at all. With the supposedly new chip, a B4 revision, it gets driven nuts as the coil is de-activated. I've had a 10nf tantalum cap across the coil and it seems to behave OK. Just going to try slightly smaller ones as this is nearly the size of the unit itself |
|
|
|