I am creating a program for a DSP processor. I have a bunch of static addresses and registers which are required to read and write from. So, I would like to assign a name to each address to make the programming easier and clearer to read. The problem is I cannot find a way to assign the pointer's location address to the value of the constant.
Does any one know a way or a better method to accomplish this?
Sorry, I am very new to this. I have never used C for this before, I had C courses a long time ago and have reviewed the language tutorial on this site. I have been using assembly for other projects.
I have a port at memory location 0x90090040 and want to relate to it as a constant name say USB_port.
and I will want to write a value to it or read a value from it.
This is what I would think would have worked for setting the value of the pointer, but it will not compile. I get this:error: a value of type "unsigned int" cannot be assigned to an entity of type "unsigned int *"
What you proposed does compile, but I do not understand its use. I am not using strings.
Memory location would be an unsigned integer. The pointer's address value represents what ???? (an entity?). I would be writing a hex value to the location or register (unsigned integer?)
Ah. Thanks. Just use the constant directly, and make it of the correct type:
1 2 3 4 5 6 7
unsignedint* const USB_data = (unsignedint*)0x90090040;
int main() // main ALWAYS returns int!
{
*USB_data = 10; // place the value 10 at the address
...
}