where are things like DDRB DDRD PORTD PORTB defined
they are used like this (taken from others code)
DDRD=0xFC; // direction variable for port D - make em all outputs except serial pins 0 & 1
DDRB=0xFF; // direction variable for port B - all outputs
PORTD = 0xFC; // all outputs except serial pins 0 & 1
PORTB = 0xFF; // turn on all pins of ports D & B
How do I find out which Arduino pins are related to for example DDRA on my Arduino Mega 2560? I've looked the 2560 datasheet but could only find 2 occurences of "DDRA" and there isn't much infos (I know I will not find anything realted to Arduino in that datasheet but I'm trying to understand...).
The I/O ports are labeled with a letter of the alphabet. For example, DDRA is the data direction register for I/O port A.
Physical pins are label with "P" then the port letter (e.g. "A") then a bit number from zero through seven. For example, physical pin 75 is labeled "PA3" which is I/O port A bit 3.
Typically, all the I/O ports have very similar characteristics and register sets. Instead of referring to the data direction register for each and every I/O port, the documentation usually uses "DDRx" to indicate "all data direction registers" (including DDRA).
Yes thanks, but how do I find the corresponding Arduino pin of PA3 ? In fact I would like to know, which "DDR" must be used for Arduino Mega's pins 22 to 53.
Edit: Forget, I think I've found some useful infos in hardware\arduino\variants\mega\pins_arduino.h
guix:
Yes thanks, but how do I find the corresponding Arduino pin of PA3 ? In fact I would like to know, which "DDR" must be used for Arduino Mega's pins 22 to 53.
This worksheet may help you. If has the 'arduino pin number' in the first column that corresponds to the AVR port/bit of the chip, either for a mega168/328p or the mega1280/2560 chips.