I Need save a value to a variable in a specified memory address.
My variable address 0xE0084000.
My variable value is 100
I Need save a value to a variable in a specified memory address.
My variable address 0xE0084000.
My variable value is 100
Is the value to occupy one byte in memory? Two bytes (16 bits)?
Code:unsigned char *addr = (unsigned char *)0xE0084000lu; /* for 1 byte */ /* or */ unsigned short *addr = (unsigned short *)0xE0084000lu; /* for 2 bytes */ *addr = 100;
That'd be possible only on a system that doesn't implement virtual memory ie there's no translation between logical and physical memory addresses because they are one and the same.
I'm using ARM 7, this address point to my SRAM.
Thanks a lot,
whats lu ?
I need to set dynamic char long int...
I create a Map of Memory to set/get values
Last edited by sergioms; 03-22-2011 at 02:24 PM.
"lu" (small "L", small "U") is a suffix that makes the compiler should interpret the constant as an unsigned long integer. Because from the hex value I assume the address is 32 bits. If you left off the "lu", the compiler might start off assuming the constant is an int, and on systems where the native int size is 16 bits, the compiler would complain about overflow when trying to interpret 0xE0084000.
I don't know what you mean: "I need to set dynamic char long int..."
Yes you can set the address dynamically:
Code:unsigned char *addr; addr = (unsigned char *)0xE0084000lu; /* for 1 byte */ /* or */ addr = /* get value from someplace */ *addr = 100;
Last edited by nonoob; 03-22-2011 at 02:31 PM.