10 years ago.

Absolute Variable Location fo ST nucleo

Hi to all i have this problem i want use the STM Studio for debug and diagnose my software, i use keil ide for write my software, in user manual i read that i have to use a Absolute Variable Location, but i don't know how to do. i write this easy code

mbed and stm studio

#include "mbed.h"
DigitalOut myled(LED1);
int i;

int main() {
i=0;
    while(1) {
        myled = 1; // LED is ON
        wait(0.2); // 200 ms
        myled = 0; // LED is OFF
			i++;
        wait(1.0); // 1 sec
    }
}

in Language Extensions of keil documantation http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm, i see this:

int xdata i         _at_ 0x8000;   /* int at xdata 0x8000 */

but i have this error "error: expected ';' after top level decalration", can you help me? Best Regards A.

1 Answer

10 years ago.

For STM Studio and mbed online compilator (because lack map or elf files), i use global variables definitions like this:

volatile int i __attribute__((at(0x20001000)));
int licz __attribute__((at(0x20001010))) =0;

and manualy copy these addresses to STM Studio. Address values in definitions are not critical but depend on the size of the RAM. It's better to be somewhere closer to the begin of RAM (but not in begin) in area of static variables.

Accepted Answer

thanks all work well, now i have this question if i want use two variable for example int i,j; the i start to 0x0x20001000, which value i use for andress of j variable?

best regards

posted by Antoniolinux B. 26 Nov 2014

Because int i variable has four bytes are the smallest address for the variable j, in this example, is 0x0x20001004. But may be larger. Since linker will leave space between the variables or insert there some variables that are not absulute.

posted by Nothing Special 26 Nov 2014