cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Allocation of variables

julienboulay09
Associate II
Posted on June 20, 2013 at 15:34

Good afternoon everyone,

I'm currently working on a ST32 chip and i'm coping with a little issue.

My problem is that I need to know where are stocked my variables in the memory when i declare them in my main so that I can modify them thanks to a Modbus TCP/IP protocol. 

Unfortunately when I execute my programm with the debugger the addresses are sometimes changing while i dont touch them...

Worse, sometimes they dont appear at all in the debugger. 

Until now the only fixed adresses i've been able to obtain are in the RAM (0x2000xxxx) but i can only get them thanks to pointers...

(I'm using Ride7 to debugg)

If you have any idea of where i should first look that would be very helpful.

Regards

Julien
1 REPLY 1
jpeacock2399
Associate II
Posted on June 20, 2013 at 15:52

I use a table in flash to translate Modbus register numbers to locations in SRAM or flash.  Assign any variables you use with Modbus as global in scope, then you can use the pointer address in the table to locate it.  You can add metadata to the Modbus register table to track the size of the variable (8, 16, 32) so your Modbus functions can translate any size mismatch.

Hardcoding an address is a pain and I don't recommend it.  Let the compiler do the work for you.  I have about 500 Modbus registers so a hardcoded address map would be a nightmare to maintain.

  Jack Peacock

  Jack Peacock