Direct I/O reads/writes from C programs

Art Berggreen art@acc.com
Wed Mar 17 11:44:00 GMT 1999


>
>As far as memory mapped I/O, there have been some recent posts here on that
>subject, but one possibility is something like this:
>
>unsigned char * addr = (unsigned char *) 0x12345678;
>unsigned char ch;
>
>/* to write 0x10 */
>*addr = 0x10;
>
>/* to read a byte */
>ch = *addr;

It might be a good idea to declare addr as pointing to a volatile to
avoid undesired compiler optimization.

i.e.:
volatile unsigned char * addr = (unsigned char *) 0x12345678;

If addr can't be modified, it can be declared as a const pointer:
volatile unsigned char * const addr = (unsigned char *) 0x12345678;

Art

_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.



More information about the crossgcc mailing list