View previous topic :: View next topic |
Author |
Message |
iso9001
Joined: 02 Dec 2003 Posts: 262
|
Odd Reset on debugging. Code Design or ICD ? Very Worried. |
Posted: Tue Aug 12, 2008 4:46 pm |
|
|
Hi,
I'm not sure if its a CCS ICD problem so that's why I'm posting in the General forum.
I'm having a problem with my setup resetting. It seems to only be when I hit the Skip Over or Run to Cursor commands.... weird I know. The issue just started today after weeks of on and off program/debugging.
I finally figured out what is going on and I set up a restart_cause() at the main to capture what was going on. On normal boots I get an 0x0C - Normal. If I set a break point anywhere and hit the skip over button the chip restarts and I get an 0x0F MCLR FROM RUN.
Has anyone ever seen this before? I have the MCLR pulled up to 5V via a 47.5k resistor, and of course MCLR tied to the ICD.
I'm falling behind on a project and I need to know if its a design problem or an ICD issue.
Thank you for any information you can add! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 12, 2008 5:10 pm |
|
|
You have to tell us your PIC and compiler version. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Tue Aug 12, 2008 5:20 pm |
|
|
Sorry, forgot to include that
3.249 (I dislike 4.0) and an 18F4585
If I remember correctly I did pull that jumper inside the icd to allow 5V to target access but this problem has never occurred before so I doubt that is it. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Tue Aug 12, 2008 5:43 pm |
|
|
One observation I just noticed,
The program will only reset itself once. Its just the first time I hit Step Over or Run to Cursor. After that step or run works fine.... wtf !? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 12, 2008 5:55 pm |
|
|
Restore your source code to the last revision before this problem
occurred (Save the current revision first). Then see if you still
get the problem. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Aug 13, 2008 11:46 am |
|
|
Old code does the same thing. I'm going to try stepping over right after main, I suspect it will happen anyway.
I'm thinking the ICD is dropping or browning out the mclr. I've got more testing to do.
I suppose I could also try the MCLR fuses.
No one else has seen anything like this ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 13, 2008 12:06 pm |
|
|
If you can afford it, get an alternate debugging system. Buy an ICD2
and download MPLAB. Then if the CCS debugger fails for whatever
reason, you have complete alternate debugging system available.
Your project doesn't stop. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Aug 13, 2008 1:54 pm |
|
|
I though I had bought a reliable tool and didn't know I would be needing a spare.
Here is code:
Code: |
#include <18F4585.h>
#fuses H4,NOLVP,NOWDT,PUT,NOBROWNOUT,NOSTVREN
#use delay(clock=40000000)
#define DEBUG TRUE
#use rs232(DEBUGGER, XMIT=PIN_B5, RCV=PIN_B5)
int temp;
void main() {
temp = restart_cause();
printf("Restart - %2X\n", temp);
printf("INIT\n");
temp=5; //BREAK POINT HERE
printf("testing");
while(1);
} //eom
|
Here is the output when I press step over twice starting at the break point at temp=5
Code: |
Restart - 0C
INIT
Restart - 0F
INIT
testing
|
I could include the lst but this is BS. Something is obviously broken!
I'm out of ideas and running out of time, a broken ICD is really going to screw me. I'll get on the phone with CCS a little later today.
Does anything look wrong that I'm missing ? |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Aug 13, 2008 4:38 pm |
|
|
I changed the sample code to do more writes to the temp variable, it didn't reset until it got to the printf again..... hmmmmm |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Aug 13, 2008 4:51 pm |
|
|
HA!
Check this out, stepping over these lines is fine:
Code: |
temp=5;
temp=3;
temp=1;
|
BUT, stepping over the middle line here causes a reset
Code: |
temp=5;
temp = temp/764;
temp = 1;
|
Now I'm stumped.... but this can rule out a faulty design on the pcb correct? Since the chip doesn't actually draw more power on a harder operation I think the chance this is noise related is greatly reduced. That and the problem just started happening all of a sudden, |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 13, 2008 5:08 pm |
|
|
1. Make a short test program that contains only that code, with a
while(1) statement at the end of main(). See if you still get the problem.
2. Take it out of PLL mode. Change the fuse and the #use delay()
statement to run it at 10 MHz. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Aug 13, 2008 5:24 pm |
|
|
Look at the code above, I DID make a basic code, that one a couple posts up is complete.
That was a good idea with the PLL, but no change. I changed 40 to 10 and made the fuse HS, same reset at the same spot. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1912
|
|
Posted: Wed Aug 13, 2008 5:55 pm |
|
|
Do you have a decent scope? Can you scope the MCLR pin, single shot or normal triggering on a falling edge, and set the threshold to whatever your actual Vdd is minus .2 or .3V? Do the same for Vdd if MCLR is stable. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Thu Aug 14, 2008 11:45 am |
|
|
Yes, I do have a scope.
I'll get it on the mclr pin today. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Thu Aug 14, 2008 3:12 pm |
|
|
Okay, got the scope on it. very odd indeed,
Everything looks fine to me. The 5V supply is steady and noise free (see Image1, that was me touching the probe to 5V in the pic).
On a user invoked chip reset (red button) the chips MCLR drops to 0 then jumps up for a moment then back down to 5V steady. Iirc, this is what should happen. Image2
On all commands (Go, Step, Step Over, RunToCursor) the MCLR and 5V supplies are very steady. No changes on reset, other then a couple pixel variance on my scope. Image3
Any thoughts !?[/img] |
|
|
|