From: Dave H. <dhy...@gm...> - 2007-12-09 03:00:53
|
Hi Mathias, > This depends on the compiler/header files you use. For example, > gcc for avr has defines for all these I/O-registers. The include files > distinguish between registers that in I/O- and memory-space, and the > compiler will then generate the correct code to access them. > > Snippets from /usr/avr/include/avr/iom128.h (ATmega128): > > /* Timer/Counter 1 Control and Status Register */ > #define TCCR1B _SFR_IO8(0x2E) > > is in I/O space and can be access with IN and OUT instructions, whereas > > > /* Timer/Counter 3 Control Register B */ > #define TCCR3B _SFR_MEM8(0x8A) > > is in memory space and must be accessed with direct addressing > (LDS/STS) or X, Y, or Z register indirect. > > At least in gcc, you don't need to have functions to read/write to/from > I/O registers or ports, but can use them like any scalar variable. > > What development system/compiler/library are you using, Paul? I'll interject here. Paul's code runs on the gumstix, and not on the AVR, so including the AVR header files isn't an option. I had created i2c-io which also runs on the gumstix and it allows the registers to be referred to symbolically. I'm assuming that Paul copied the defines from that source file, but I could be wrong. It talks to the portion of i2c-io that runs on the robostix, and it just gets a register address and a value and it stores the value at the address so it always uses the memory mapped address and not the I/O address. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |