Where is DDRB etc defined

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

want to see what else I can access directly

eg is portE in 32u4 defined (Leonardo ) ?

Thanks in advance for any guidance

In the avr includes for your install of avr-gcc. For me on Ubuntu the relevant file is
/usr/lib/avr/include/avr/iom328p.h

The AVR datasheet for the chip you are interested in is a good source of information for such information.

Lefty

They are defined in the device header file, together with all other good stuff. A must read if you want to program a mcu.

dhenry:
They are defined in the device header file, together with all other good stuff. A must read if you want to program a mcu.

Soo the header file for the device is in the device header file? Helpful.

I wouldn't say reading header files is recommended for people just using them; the documentation is definitely better: avr-libc: Modules And the datasheet is also very helpful: http://www.atmel.com/devices/atmega328p.aspx?tab=documents or http://www.atmel.com/Images/doc8271.pdf

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

Does that help?

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 :slight_smile:

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.

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

Lefty

Might be useful, thanks :slight_smile:

google for "arduino mega pin mapping" or "arduino uno pin mapping"

both turn up good results.

try this tutorial.

tutorial5.pdf (116 KB)

How do I find out which Arduino pins are related to for example DDRA on my Arduino Mega 2560?

Google arduino pinout and see the images.

Thanks for all the the replies very helpful.

Haven't had time to work out if that gives me access to PE2 on the 32U4 yet.

On the Mac, the io files are found in:
/Applications/Arduino 4.app/Contents/Resources/Java/hardware/tools/avr/avr/include/avr/

Lot's of architectures:
io.h io86r401.h iom1281.h iom2561.h iom48.h iomx8.h iotn261.h iousb1287.h
io1200.h io90pwm1.h iom1284p.h iom32.h iom48p.h iomxx0_1.h iotn28.h iousb162.h
io2313.h io90pwm216.h iom16.h iom323.h iom64.h iomxx4.h iotn43u.h iousb646.h
io2323.h io90pwm2b.h iom161.h iom324.h iom640.h iomxxhva.h iotn44.h iousb647.h
io2333.h io90pwm316.h iom162.h iom325.h iom644.h iotn11.h iotn45.h iousb82.h
io2343.h io90pwm3b.h iom163.h iom3250.h iom645.h iotn12.h iotn461.h iousbxx2.h
io43u32x.h io90pwmx.h iom164.h iom328p.h iom6450.h iotn13.h iotn48.h iousbxx6_7.h
io43u35x.h ioat94k.h iom165.h iom329.h iom649.h iotn13a.h iotn84.h iox128a1.h
io4414.h iocan128.h iom165p.h iom3290.h iom6490.h iotn15.h iotn85.h iox128a3.h
io4433.h iocan32.h iom168.h iom32c1.h iom8.h iotn167.h iotn861.h iox256a3.h
io4434.h iocan64.h iom168p.h iom32hvb.h iom8515.h iotn22.h iotn88.h iox256a3b.h
io76c711.h iocanxx.h iom169.h iom32m1.h iom8535.h iotn2313.h iotnx4.h iox64a1.h
io8515.h iom103.h iom169p.h iom32u4.h iom88.h iotn24.h iotnx5.h iox64a3.h
io8534.h iom128.h iom16hva.h iom32u6.h iom88p.h iotn25.h iotnx61.h
io8535.h iom1280.h iom2560.h iom406.h iom8hva.h iotn26.h iousb1286.h