2016-07-14 08:27 AM
I'm using an STM32L151 board and I want to know how to map a memory address to its function. For example:
LDR.W R0, =0x20002A20
MOVS R2, #4
MOVS R1, #4
STR R1, [R0,#0x14]
LDR.W R1, =0x20002224
STR.W R2, [R1,#0x1B8]
In a rough translation to pseudocode, we see that:
R0 = *(0x20002A20)
R1 = 4
R2 = 4
The 4 bit is set to one on memory address of R0 + 0x14
R1 = *(0x20002224)
The 4 bit is set to one on memory address of R1 + 0x1B8
But I am having a hard time figuring out what the code is actually doing. I know it is in the SRAM (according to the memory map) but I cannot find the 0x2A20 or 0x2224 address offset does. I've been looking in the header files (like stm32l151xc.h) and cannot find anything. Once I know how to find what these addresses map to, I can see what setting the 4 bit to ''on'' does. How do I find what 0x2A20 and 0x2224 map to? Where should I
2016-07-14 09:40 AM
It is not going to be in the manuals or include files.
The address comes from where the linker places specific variables you have allocated, mostly on a first come first served basis. You can review the symbols exported by the linker in the .MAP file (or within the .AXF/.EXF object). For structures or arrays you might only get the address of the base, and the length, and you'd have to figure if the address falls within that.