embeded/AVR (ATmega,ATtiny)2011. 12. 28. 07:57
매번 헷갈리는 지라...
아무튼  PORT는 값을 쓰는 용도
PIN은 값을 읽어 들이는 용도
DDR은 읽는용으로 쓸지 쓰는 용으로 쓸지를 정해주는 용도이다.
DDR 값이 0 이면 PORT 에 쓰고
DDR 값이 1 이면 PIN 으로 읽어 오면 된다.

PORTA - Port A Data Register
DDRA  - Port A Data Direction Register
PINA  - Port A Input Pins Address 

The DDxn bit in the DDRx Register selects the direction of this pin.
If DDxn is written logic one, Pxn is configured as an output pin.
If DDxn is written logic zero, Pxn is configured as an input pin. 

Three I/O memory address locations are allocated for each port,

one each for the Data Register - PORTx,
Data Direction Register - DDRx,
and the Port Input Pins - PINx.

The Port Input Pins I/O location is read only, while the Data Register and the Data Direction Register are read/write.
In addition, the Pull-up Disable - PUD bit in SFIOR disables the pull-up function for all pins in all ports when set.

[링크 : http://www.atmel.com/dyn/resources/prod_documents/doc2467.pdf] 

[링크 : http://donghwada.tistory.com/entry/ATmega-Pin-Configurations-DDR-PORT-PIN]
Posted by 구차니