ATmega will only load half of program

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am working on a project using the ATmega88PA, Atmel Studio 7 (version 7.0.1931), and the Atmel-ICE debugger.  I'm able to program the ATmega88PA using the Atmel-ICE in ISP mode and my program runs as expected.  However, when I try to debug, a curious behavior occurs: After enabling debugWire, Atmel Studio writes about 60% of the program (according to its status bar), then says "Running," and eventually I get a message saying "Launch Failed:  Timed out waiting for device to reset, would you like to continue waiting for the reset event?"

 

The problem arose suddenly during development without hardware changes.  My code is large; the hex file is 8192 bytes or 100% of flash.  Could that contribute to this?  What debugging steps should I take to isolate my problem?

 

Thanks,

 

Adam J.

This topic has a solution.

Last Edited: Wed. Dec 5, 2018 - 04:56 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would start by looking over your reset line. debugWire is very sensitive to load on the reset line...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

adamj537 wrote:
My code is large; the hex file is 8192 bytes or 100% of flash. Could that contribute to this? What debugging steps should I take to isolate my problem?

I would solder in a M328 to give yourself some room to debug!  Once the the program works and you know the code space needed, choose the appropriate Mega and recompile.

I always do my prototyping/debugging using the largest member of the family, it makes (programmers) life much easier.

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

adamj537 wrote:

My code is large; the hex file is 8192 bytes or 100% of flash.  Could that contribute to this?  What debugging steps should I take to isolate my problem?

 

How are you determining that? It just feel odd that you have managed to write code that fills the full 8K exactly, neither a byte under nor byte over.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also sizeof(hex file) != sizeof(binary).

 

Usually .hex is 2.5 to 3.0 times larger than the binary. So if hex is really 8192 bytes then it's probably about 2,700..3,700 bytes of code - avr-size will tell you the exact size held within.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for the delay in replying.  The source of my problem appears to have been that there was a bit-banged I2C sensor using the same pins as the debugWire.  That's what I get for doing a contract job on someone else's hardware, and not paying close attention to the schematic ;)

 

I was able to enter debugWire by removing the sensor and using a JTAGICE mkii instead of the Atmel-ICE.  Not sure why changing debug tools helped, but it did.

 

Regarding code size, I was referring to the size in bytes reported in the compiler output in Atmel Studio; I took a long time coaxing all the required features to fit and that's why it's such a close fit.  And yes, I wholeheartedly agree with the comment to use a bigger chip for development.  This was a quick enhancement on an existing product.

 

Thanks all!

 

Adam J.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

adamj537 wrote:
a bit-banged I2C sensor using the same pins as the debugWire.

Doesn't debugWire use the /RESET line?  And you have the bit-banged I2C on the /RESET line? 

 

Now I have to dig out datasheets and past threads -- does debugWire even work if RSTDISBL fues is programmed?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Wed. Dec 5, 2018 - 01:54 PM