The megaAVR and AVR Dx families are not pin-to-pin compatible. Thus, the GPIO basic functionality is similar and is configurable using three registers for both families:
megaAVR® | AVR® Dx | Description |
---|---|---|
DDRx | PORTx.DIR | Data direction - controls the data direction (output driver) |
PORTx | PORTx.OUT | Data out - controls the output driver level for each PORTx pin |
PINx | PORTx.IN | Data in - shows the state of the PORTx pin |
The following code snippets show how to configure the PORTA pin 7 as output-driven high for each family.
{
DDRA =0x80;
PORTA =0x80;}
{
PORTA.DIR =0x80;
PORTA.OUT =0x80;}