View previous topic :: View next topic |
Author |
Message |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
possible processor problem |
Posted: Wed Oct 29, 2008 7:00 am |
|
|
My PIC16f877a seems to be crashing and all the pins start to oscillate extremely fast (as seen on the Digital Analyzer).
This happens when I change code, it doesn't matter what is added or taken away.
It has just started to do this and I have been reprogramming it will success for about a month.
The chip is on a PCB that has given no troubles in the past.
Could the chip be going bad? It has been reprogrammed a lot but it is no where near the life expectancy of the program flash memory.
Also when this happens the voltage regulator seems to "whine" but when the power is reset everything is fine until it goes back into the oscillating state. |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Wed Oct 29, 2008 7:56 am |
|
|
Your statement that the regulator starts to whine raises a red flag for me. Does your power supply rail oscillate as well? If so, it sounds like you don't have enough capacitance on Vcc to ground. |
|
![](templates/subSilver/images/spacer.gif) |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Oct 29, 2008 7:59 am |
|
|
everything is fine on the voltage rail.
I went and commented out a few things and got it working but the funny thing is i went and uncommented them out and added it back in and it works now...
Dang ghost need to get out of the devices lol |
|
![](templates/subSilver/images/spacer.gif) |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Oct 29, 2008 8:36 am |
|
|
One of the culprits happens to be when I run the function memset(channel1, 0, sizeof(channel1));
channel1 is a 100 element array. I am using memset to set the array back to 0's.
I also have tried using a for loop to run through each element and set it to 0 but the same thing also happens.
Any thoughts? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Oct 29, 2008 9:01 am |
|
|
i have already removed that code from my source file.
I took a look at the link you posted. I can declare the 100 element arrays without problem but I have to use #locate channel1 = 0xA0 after it so the compiler doesn't give me the out of memory error. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 29, 2008 10:13 am |
|
|
Quote: |
I can declare the 100 element arrays without problem but I have to use
#locate channel1 = 0xA0 after it so the compiler doesn't give me the out
of memory error. |
Look at the memory map for the 16F877A in the data sheet.
It's on page 17 (page 19 in the Acrobat Reader), and it's titled:
FIGURE 2-3: PIC16F876A/877A REGISTER FILE MAP
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
It shows there is only 96 continuous RAM bytes available in that location.
So if you tried to use the last 4 locations in that array, you would
overwrite the Indirect Register, PCL, TMR0, and Status. This would
certainly cause erratic behavior or a crash.
Quote: | I have already removed that code from my source file. |
Remove anything else in the code that is similar to this. |
|
![](templates/subSilver/images/spacer.gif) |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Oct 29, 2008 10:18 am |
|
|
You are right sir. I double checked the memory map and opened my eyes and realized what my problem was. |
|
![](templates/subSilver/images/spacer.gif) |
|