You need to log in to create posts and topics.

Real Initial Values of RAM Registers

ATmega8 (or AVR family)

The real initial value of each RAM register whose address is from 0 to end of SRAM (excluding the I/O ones) could be any 8-bit number (a random number) after an MCU boot (after a hardware reset).

In the two MCU simulators which I know (Atmel Studio and simulIDE), the case is different. The initial value is simply set to zero instead. This may fool the writer of a code in case he forgets initializing some RAM registers. And while his code works fine when it is run by the simulator, he gets a different (chaotic) result when run in real.

For this, I suggest, if this is possible, to add an option (in MCU properties) by which the user can choose the initial value for the RAM registers to be an 8-bit number instead of ‘zero’ (the default one). There is no need to make it random. This may help a lot in debugging some codes mainly if the SLEEP instruction is used.

Any idea?

Kerim

Yes, I think it could be interesting to add an option to not clear RAM.

Personally I ussually prefer to start from a cleared RAM to see what is happening, if there are already some values I don't know if they are from this run or a previous one.

But as you mention in some cases this could lead to a diferent behavior than the real device.