Go Down

Topic: Where is DDRB etc defined (Read 2 times) previous topic - next topic

guix

#5
Nov 20, 2012, 06:29 am Last Edit: Nov 20, 2012, 06:34 am by guix Reason: 1
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...).

Coding Badly


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).

Does that help?

guix

#7
Nov 20, 2012, 06:52 am Last Edit: Nov 20, 2012, 06:54 am by guix Reason: 1
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 :)

retrolefty


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.

https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Lefty

guix


Go Up