AnsweredAssumed Answered

Memory locations being incorrectly written to?

Question asked by Richard Howell on Jul 27, 2020
Latest reply on Jul 27, 2020 by ZhangJennie

I am reluctant to think this problem is with my processor, so I'm posting here under the assumption that it is perhaps a setting I am uninformed of when it comes to my dev environment / debugger.


I am writing an embedded application for a MC9S08QE32 product used on a wireless radio product within CodeWarrior dev studio for MCU, v 10.2). When I compile my code and go into debug mode with my MultiLink Universal device, I am getting some strange behavior during the very basic initialization portion of my main() function.


As you can see in the attached picture, when I step through the initialization line for line, everything is OK until I get to:


 ... which is a u16. At this point, as you can see on the Variable tab on the right, it updates the value in prv_prs_avg to 0, but also updates drop_count in the process, presumably because the u16 is spanning or overlapping this memory location. Does anyone know what causes this to occur, or why the system would assign a variable to a memory location that was already allocated? It also appears to be modifying 0x0725 and 0x0724, but shouldn't it be attempting to change 0x0725 and 0x0726 (U16 = 2B)?