Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: November 19, 2012, 10:11:46 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 76
Posts: 6849
Arduino rocks
|
 |
« Reply #1 on: November 19, 2012, 10:32:01 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #2 on: November 19, 2012, 11:16:50 am » |
The AVR datasheet for the chip you are interested in is a good source of information for such information.
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #3 on: November 19, 2012, 05:52:32 pm » |
They are defined in the device header file, together with all other good stuff. A must read if you want to program a mcu.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
France
Offline
God Member
Karma: 23
Posts: 648
Scientia potentia est.
|
 |
« Reply #5 on: November 20, 2012, 12:29:08 am » |
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...).
|
|
|
|
« Last Edit: November 20, 2012, 12:34:18 am by guix »
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Online
Shannon Member
Karma: 129
Posts: 10377
|
 |
« Reply #6 on: November 20, 2012, 12:43:16 am » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
God Member
Karma: 23
Posts: 648
Scientia potentia est.
|
 |
« Reply #7 on: November 20, 2012, 12:52:36 am » |
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 
|
|
|
|
« Last Edit: November 20, 2012, 12:54:10 am by guix »
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #8 on: November 20, 2012, 12:56:20 am » |
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=0Lefty
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
God Member
Karma: 23
Posts: 648
Scientia potentia est.
|
 |
« Reply #9 on: November 20, 2012, 01:03:14 am » |
Might be useful, thanks 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 16
Posts: 1036
Arduino rocks
|
 |
« Reply #10 on: November 20, 2012, 02:08:55 am » |
google for "arduino mega pin mapping" or "arduino uno pin mapping"
both turn up good results.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 4
Posts: 187
|
 |
« Reply #11 on: November 20, 2012, 04:43:20 am » |
try this tutorial.
|
|
|
|
|
Logged
|
From Idea To Invention
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #12 on: November 20, 2012, 06:53:12 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #13 on: November 20, 2012, 03:44:47 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
|