Author Topic: program and debug AVRs without a serial interface  (Read 956 times)

0 Members and 1 Guest are viewing this topic.

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 442
  • Country: ca
    • Nerd Ralph
program and debug AVRs without a serial interface
« on: June 04, 2015, 08:21:03 am »
I made a simple and small (18-byte + 4 byte setup) function to use the EEPROM as a circular debug log, which then can be read with the same programmer used to flash your code.
http://nerdralph.blogspot.ca/2015/06/avr-eeprom-debug-log.html
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1595
  • Country: gb
Re: program and debug AVRs without a serial interface
« Reply #1 on: June 04, 2015, 10:01:50 pm »
Just be aware that the lengthy write time of the EEPROM could easily cause timing related bugs in your code, particularly when writing long strings.

Also if you held the EEPROM log address in a separate variable rather than relying on the value in EEARL being correct, then your code could use different areas of the EEPROM for other purposes (e.g. calibration values).  Obviously this would require an extra byte of SRAM.
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 442
  • Country: ca
    • Nerd Ralph
Re: program and debug AVRs without a serial interface
« Reply #2 on: June 04, 2015, 11:19:39 pm »
For debugging timing-critical code, neither eeprom nor serial is practical.  For that I'd use a logic analyzer or scope.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1595
  • Country: gb
Re: program and debug AVRs without a serial interface
« Reply #3 on: June 07, 2015, 08:15:27 pm »
For debugging timing-critical code, neither eeprom nor serial is practical.  For that I'd use a logic analyzer or scope.

The point I was making is that it takes so long to write to EEPROM, that even code that wouldn't normally be considered timing critical could fail.  It's not a few microseconds you are tying up the micro for, it's a few milliseconds for each character which could quickly add up to many 10's or 100's of milliseconds for a string.

It would be most useful for an error handler that stops the main process running completely, and then writes a message log with e.g. stack information etc.
 

Offline nuno

  • Frequent Contributor
  • **
  • Posts: 538
  • Country: pt
Re: program and debug AVRs without a serial interface
« Reply #4 on: June 07, 2015, 10:18:47 pm »
If the micro is so small that I can't spare even a single pin to make a dataout debug serial-something interface, I run it heavily under simulation 1st or develop in a bigger chip.
But the EEPROM method can still be useful, like for logging exceptional conditions on the field for later analysis :-+
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 442
  • Country: ca
    • Nerd Ralph
Re: program and debug AVRs without a serial interface
« Reply #5 on: June 07, 2015, 11:32:09 pm »
I agree eeprom writes are slow.  My point is that *both* serial and eeprom are slow.  9600bps takes 1ms per character vs ~3ms for eeprom writes.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf