Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Arduino AVR not fixed by reset
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Arduino AVR not fixed by reset

by FazJaxton on Wed Jun 09, 2010 1:03 am

I have made a program for AVR to poll a separate transceiver chip over SPI and print out any messages it finds over serial. I am using Arduino as a development platform, but am programming directly for the AVR with avr-gcc and avrdude. It seems to work okay for anywhere from around 5 to several dozen messages, but then it hangs up. It just stops, then seems to continuously reset, never getting out of the bootloader. (When working normally, I notice that the surface mount LED flashes during the bootloader. I see it flash repeatedly at about 1 second intervals, so it appears to be repeatedly resetting).

My software may very well be bad, sending the CPU off who-knows-where, but I am not sure what can go so wrong that a reset, or even a complete power off and on won't fix it. I have to reprogram the device to get it to work again. What can happen to make it do this?
FazJaxton
 
Posts: 59
Joined: Mon Sep 28, 2009 2:18 pm
Location: Kansas, USA

Re: Arduino AVR not fixed by reset

by franklin97355 on Wed Jun 09, 2010 5:29 pm

If you by mistake have a write to a location that resides in the program space this could be a result. It may be a specific combination of data read or the number os sum of numbers that causes the out of range write but with c this is allowed by the language and has happened to others before.

franklin97355
 
Posts: 21586
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Arduino AVR not fixed by reset

by FazJaxton on Sun Jul 18, 2010 5:46 pm

Thanks for the reply. From reading the Atmel datasheets, it looks to me like the program memory space is only writable by the SPM instruction and that the SPM instruction is only enabled while executing code in the boot loader. If this is true, then it should not be possible for a running program to overwrite itself. It also looks like the RAM address space and the program address space are separate address spaces, so even if it was possible, it wouldn't occur by accident. Is it still possible for this to be the problem?
FazJaxton
 
Posts: 59
Joined: Mon Sep 28, 2009 2:18 pm
Location: Kansas, USA

Re: Arduino AVR not fixed by reset

by mtbf0 on Sun Jul 18, 2010 9:27 pm

FazJaxton wrote:Thanks for the reply. From reading the Atmel datasheets, it looks to me like the program memory space is only writable by the SPM instruction and that the SPM instruction is only enabled while executing code in the boot loader. If this is true, then it should not be possible for a running program to overwrite itself. It also looks like the RAM address space and the program address space are separate address spaces, so even if it was possible, it wouldn't occur by accident. Is it still possible for this to be the problem?


nope, but if your strings get too long you could be overwriting the stack.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Re: Arduino AVR not fixed by reset

by FazJaxton on Mon Jul 19, 2010 11:38 am

Good idea; I hadn't thought of that. But I would think that it would work again after reset and not need to be reflashed.
FazJaxton
 
Posts: 59
Joined: Mon Sep 28, 2009 2:18 pm
Location: Kansas, USA

Please be positive and constructive with your questions and comments.