I want to grok the logic behind I/O on Atmega128 and I am a newbie. I thought I understood it, but an recent assignment at school made me rethink my position. Let me lay out a easy example.
I want to configure PORTA as input and PORTB as output. Then all I have to do is this, right? (Assuming that I program in C atm ... )
DDRA = 0x00; (default) DDRB = 0xFF;
Now if I a switch is plugged into bit0 on PORTA, and I want to read PORTA, then the value coming from PINA should be 0x01 right, if the switch is pressed?
If I am correct so far, the assignment says that If I read 0 from bit0, then it means that the switch is pressed. Now, how to I configure the PORTS according to that specification?