What is the difference between reading PORTA and PINA?
What is the relation between a port and its pins?I'm really confused!!!
sample of reading PORT:(reading pin is not useful here)
Assembly
f=1MHZ
ATmega8
I need to complement PORTB every 1ms.(Dutycycle=50%)
LDI R16,$FF
OUT DDRB,R16
MAIN: LDI R16,00
DELAY:CPI R16,200
BREQ LOOP
INC R16
RJMP DELAY
loop:IN R17,PORTB
COM R17
OUT PORTB,R17
OUT R17,PORTB
RJMP MAIN
Best Answer
PORT is the OUTPUT buffer, PIN is the INPUT buffer.
When you want to set the pin to a "high" or "low" voltage, write to the PORT register.
When you want to know what voltage is currently presented to a pin, read the PIN register.
The bits of these registers represent the corresponding pins of the general-purpose input/output port.
Here is a simplified schematic of the electronics inside the AVR connected to a single pin (go here for complete datasheets).
This circuit block is repeated for each pin. Eight of these form a port (port A, for example).
Starting at the left-most square (which represents the physical connection to the outside world), you can see three paths:
It should be noted that some or all of this circuitry can be bypassed when the pin is shared with an internal peripheral. For example, the Analog-to-Digital Converter (ADC).