I only use C a few times a year and then I forget all over how to do stuff with it. I am trying to write to a device connected to CS3. I tried this little routine that goes:
void RegOut (char regnum,char value)
{
long * address;
address = 0x83000000;
*address = 0x55;
// address = 0x55;
}
I have tried dozens of different ways but it either doesnt compile or doesnt work. Anybody have a simple way of doing this?
Yes. I think I did the hardware setup thing correct. My problem is just that I want to move characters to various addresses inside achip selected by cs3. My c programming isn’t so good so I am running the simulator to test it and either it doesn’t work or doesn’t compile. A definite cockpit error on my part. I suspect I should establish a seperate segment but dont have that figured out yet.
Do you want “address” to be a “long *” or a “char *”? Since you’re storing chars, it seems like you might actually want it to be a char *. (An easy way to read pointer declarations in C is to interpret it as declaring that “*address” is of type “long” — that is, it’s pointing to a long.)
The code you have would convert ‘0x55’ to a ‘long’, presumably extending it with 0s, before storing it at the pointed-to address.
You might also want to declare it as “volatile”, which will keep the compiler from assuming that the address acts like RAM and possibly optimizing away an important load or store.