Pages: [1]   Go Down
Author Topic: request for correction to documentation  (Read 914 times)
0 Members and 1 Guest are viewing this topic.
Colorado, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On this Arduino web page: http://arduino.cc/en/Reference/BitwiseAnd, about half way down the page you see these two paragraphs.

Example Program
A common job for the bitwise AND and OR operators is what programmers call Read-Modify-Write on a port. On microcontrollers, a port is an 8 bit number that represents something about the condition of the pins. Writing to a port controls all of the pins at once.

PORTD is a built-in constant that refers to the output states of digital pins 0,1,2,3,4,5,6,7. If there is 1 in an bit position, then that pin is HIGH. (The pins already need to be set to outputs with the pinMode() command.) So if we writePORTD = B00110001; we have made pins 2,3 & 7 HIGH. One slight hitch here is that we may also have changeed the state of Pins 0 & 1, which are used by the Arduino for serial communications so we may have interfered with serial communication.



In the second paragraph, this sentence seems wrong: So if we writePORTD = B00110001; we have made pins 2,3 & 7 HIGH. It should say we have made pins 5,4, & 0 HIGH, or else change the binary number to B10001100.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes it seems to be wrong. But they do say "pins 2,3 and 7" not bits, does that map to the Arduino pins?

EDIT: I looked at the UNO schematic, the PORTD bits map directly to logical pin numbers so yes the doc is wrong.
______
Rob
« Last Edit: December 31, 2012, 06:53:39 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Colorado, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I never thought about the mapping between the mega2560 chip pins and the Arduino board pins. I was thinking strictly about the port pins on the chip itself.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That documentation is totally wrong for a Mega. PORTD is I2C, RXD1 and pin 38 on the Mega. Bits 4-6 are not connected.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: