2012-09-11 11:10 PM
2012-09-11 11:58 PM
I suggest the stm32fxxx.h files as an example, like stm32f10x.h for the F1 family.
This file(s) are found in the standard peripheral libs for the specific part, and declare all fixed peripheral addresses/registers by laying C struct over them. It is your turn, however, to make sure that you do not interfere with the compiler/linker.2012-09-12 12:15 AM
Are you sure you can't do it in other way? Writing to a fixed address is often not good idea. The best way to do it is modification of the linker script. You have to:
- reduce the .bss section to make some RAM free- make a new section in this place starting from YOUR_ADDRESS, call it for example .reserved-ramNow you can simply read or write to/from the address which is in range of your section and you don't need to worry if there are any variables inside:((uint8_t *) *(YOUR_ADDRESS + 0x01)) = i;
You can also declare the variable like that:uint8_t ReservedRam[256] __attribute__((section(''.reserved-ram'')));
and thisi = ReservedRam[3];
reads the byte from YOUR_ADDRESS + 0x03. Best regardsKonoppo2012-09-12 01:01 AM
Looks like I found the solution:
uint32_t *pointer;
uint32_t pi,pii;
//SAVING DATA
pi = 0x20000000;//RECEIVE ADDRESS AND SAVE IT INTO A INTEGER
pointer = (uint32_t*)pi; //CONVERT IT INTO POINTER
*pointer = 100; //SAVE 100 INTO POINTER (0X20000000)
//RETRIEVING DATA
pi = 0x20000000;//RECEIVE ADDRESS AND SAVE IT INTO A INTEGER
pointer = (uint32_t*)pi; //CONVERT IT INTO POINTER
pii = *pointer;//READING ADDRESS THRU THE POINTER
My linker file will have allocated region for this so the compiler won't mess around (hopefully).
2012-09-12 04:50 AM
Something I don't understand: what is your point in knowing the address ?
A variable, and it's name, are an abstraction explicitely provided for this issue. You refer to to a memory location by the name of the variable. You neither need to know, nor to care at which address it is actually located. That task is left to the compiler and the linker.2012-09-13 07:37 AM
It has to do with giving flexibility to the system design. If I have access to an specific address, then I only have one command from an external domain to read/write to that address.
Also, I can use the same command to control other configuration registers and so on.I basically have control over the processor's brain in real time ;)2012-09-13 10:43 AM
Are you thinking of something like the old BASIC PEEK and POKE commands?
2012-09-13 11:32 AM
''I basically have control over the processor's brain in real time''
More to the point, there is a veryhigh risk that you will totally derange the processor by messing with its brain carelessly and/or inappropriately!!
Sure, it can be done - but that does not mean that it should be done!2012-09-13 11:42 AM
It has to do with giving flexibility to the system design
WRONG
It has to do with inflexibility to the system design.
you will have to dig out your hex calxulator every darn time you add a variable Erik2012-09-13 04:07 PM
//SAVING DATA
*((uint32_t *)0x20000000) = 100; //RETRIEVING DATA pii = *((uint32_t *)0x20000000); If fixed/known addresses are required, perhaps it would be better to use definition files, or linker scripts