[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
The compiler uses the sfrb and sfrw keywords to access the AVR microcontroller’s I/O Registers, using the IN and OUT assembly instructions.
Example:
/* Define the SFRs */
sfrb PINA=0x19; /* 8 bit access to the SFR */
sfrw TCNT1=0x2c; /* 16 bit access to the SFR */
void main(void) {
unsigned char a;
a=PINA; /* Read PORTA input pins */
TCNT1=0x1111; /* Write to TCNT1L & TCNT1H registers */
}
The addresses of I/O registers are predefined in the following header files, located in the ..\INC subdirectory:
tiny22.h
90s2313.h
90s2323.h
90s2333.h
90s2343.h
90s4414.h
90s4433.h
90s4434.h
90s8515.h
90s8534.h
90s8535.h
mega603.h
mega103.h
mega161.h
mega163.h
94k10.h
94k20.h
94k40.h
You may #include the corresponding file, for the processor that you use, at the beginning of your program.
CodeVisionAVR C Compiler, (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
E-mail: info@telesys.ru