Can someone specify ways to a) write to and b) read from, an absolute address for ARM compiler? Microcontroller is LPC54628.
A global variable 'var' prints a certain value to serial terminal when called from main function but when this value is printed from inside an Interrupt Service Routine, it shows up as 0. If I change the initializing value for this variable to something else, say 100, then it will print 100. Can't figure out why. Hence thinking of accessing the variable by specifying the address location.
Any help would be greatly appreciated. Thanks.
It is difficult to know the problem without seeing your code, but I guess it because you have not defined your variable as volatile.
for more information, see https://www.embedded.com/introduction-to-the-volatile-keyword/
Something like this, assuming you want a 32bit read/write:
#define MY_ADDRESS (0x12345678) /* address of object *( /* read */ int32_t i = *((int32_t*)MY_ADDRESS); /* write */ *((int32_t*)MY_ADDRESS) = i;
There are of course many other ways you could do this in C/C++, e.g. do all the casting in the macro.
I hope this helps,