Real Initial Values of RAM Registers
Quote from KerimF on February 28, 2024, 7:43 amATmega8 (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
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
Quote from arcachofo on February 28, 2024, 9:35 amYes, 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.
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.