AVR Simulator 2 bug

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

I am using AVR Studio 4 version 4.19 (GUI version 4,19,0,730). I have noticed that when one comes out of the AVR Simulator 2 and then goes back in, the registers are not cleared to zero but still retain their old values.:evil: This is in contrast to AVR Simulator which clears all registers to zero when one enters into the simulation.

Has anybody else noticed this?

I always have to close down AVR Studio and start it up again and then go into the AVR Simulator 2 to get a clean slate.

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

It's a feature, not a bug :-)

This behaviour reflects the hardware implementation. Many (older) AVR devices do not explicitly clear the CPU register file on reset, and this behaviour is reflected in simulator 2. Some newer devices (like xmega) clear the register file on reset, this will again be reflected in simulator 2. (just apply a reset during a debug session to see this in effect).

You should never trust CPU registers or RAM to have specific initial values (like 0) after power-up. If your application depends on that, your application should explicitly initialize them on start-up. I/O registers on the other hand are always initialized on reset.