Go Down

Topic: request for correction to documentation (Read 1 time) previous topic - next topic

sellonoid

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.

Graynomad

#1
Jan 01, 2013, 12:36 am Last Edit: Jan 01, 2013, 12:53 am by Graynomad Reason: 1
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
Rob Gray aka the GRAYnomad www.robgray.com

sellonoid

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.

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy