Problem Using AVR Studio 4.08

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

Hi
I'm having a litte problem with AVR Studio.
I have a project loaded and compiled.
I get a warning message as follows:

C:\Program Files\Atmel\AVR Tools\Projects\Modem.asm(122): warning: A .db segment with an odd number of bytes is detected. A zero byte is added.
C:\Program Files\Atmel\AVR Tools\Projects\Modem.asm(132): warning: A .db segment with an odd number of bytes is detected. A zero byte is added.
Is this message critical? I can't seem to clear it up.

This project downloads to ICE200 no problem. Target runs fine with ICE200.
When I use the STK500 to put code into a 2313. The code does not run in target.
Any help would be great.
Thank you in advance
Don

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

Flash program memory is organized as 16 bit words. This means that the program counter is word incremented and that labels are defined on word boundaries.

When including byte defined data string (.db) with an odd number of bytes, the last word would only be half occupied. The assembler warns of the occurrence, indicating that it has added a zero byte to complete the word.

The LPM instruction uses the least significant bit of the Z pointer to select the either the low or high byte of program memory. When loading a word address (label) into the Z pointer it must left shifted once or multiplied by 2 in order to point at the desired memory word.

This may not be an issue for the newer versions of Studio, however from a project years ago I believe that ignoring the odd number of byte warnings caused the resulting code be corrupted. I had several large tables defined with .db where I ignored the warning messages. Code following those tables crashed. For all my projects now, if receiving the odd number of bytes warning, I add an extra null to the string.

Stan