Tuesday, April 27, 2010
Thursday, March 25, 2010
Friday, March 19, 2010
AVR Digital I/O Registers
Each port pin consists of three register bits: DDxn, PORTxn, PINxn.
DDxn bits are accessed at the DDRx I/O address.
PORTxn bits are at the PORTx I/O address.
PINxn bits at the PIN I/O address.
Note:
DDRx is the Data Direction Register. This register sets the data direction of individual pins of port x. A logic level of '1' sets a port pin as output. A logic level of '0' sets a port pin as input.
ex:
PORTx is the Data Register. If you have set any pins on the port as output using the DDRx register you can now control them with this register. A logic level of '1' makes a port pin high. A log level of '0' makes a port pin low.
ex:
PINx is the Input Pin Address Register. If you have set any pins on the port as input using the DDRx register you can now read the status of them with this register.
ex: Assuming a switch is interfaced to Port A Pin 0 with a pull up resistor...
DDxn bits are accessed at the DDRx I/O address.
PORTxn bits are at the PORTx I/O address.
PINxn bits at the PIN I/O address.
Note:
Each instance of 'x' should be replaced with the port identification letter (A,B,C,D, ect.)
Each instance of 'n' should be replaced with a pin number (0..7)
DDRx is the Data Direction Register. This register sets the data direction of individual pins of port x. A logic level of '1' sets a port pin as output. A logic level of '0' sets a port pin as input.
ex:
DDRB=0b00000001 // Set direction of port B pin 0 as output, all others input
DDRD=0b00100010 // Set direction of port D pin 5 and pin 1 as output, all others input
PORTx is the Data Register. If you have set any pins on the port as output using the DDRx register you can now control them with this register. A logic level of '1' makes a port pin high. A log level of '0' makes a port pin low.
ex:
PORTB=0b00000100 // Make port B pin 2 high, all others low
PORTA=0b00000101 // Make port A pin 2 and pin 0 high, all others low
PINx is the Input Pin Address Register. If you have set any pins on the port as input using the DDRx register you can now read the status of them with this register.
ex: Assuming a switch is interfaced to Port A Pin 0 with a pull up resistor...if (PINA & 0b00000001) {
// Switch interfaced to Port A Pin 0 is open
}
else {
// Switch interfaced to Port A Pin 0 is closed
}
Posted by
MrLowerr
Thursday, March 18, 2010
Prototype ATmega644P Breakout Board First Program
Loaded up my first program to my ATmega644P board today. Its just a simple program to set Pin 0 on port B as output and then loop forever toggling the the pin as high and low with a short delay in between.
Board setup and scope output.
The code is not so interesting so I wont bother posting it here. Its nothing that can not be seen in any other beginner tutorials for AVR micros around the net.
I will be doing some experimenting with the Analog-to-digital converter and dual USART ports on the ATmega644P that will probably be a bit more interesting.
Posted by
MrLowerr
Subscribe to:
Posts (Atom)