Moving data parallelly to port D

Hi,
I want to move 8 bits of data to the port D(pins 0-7 on the diecimila) simultaneously. Is there a single function that I can
use to do it?

I think I can use shiftOut() function or even manually extract the bits and send them using digitalWrite().
However, if the same thing can be done using a single function, then I would like to use that.

I am very new to arduino, so what I have asked may be silly or very naive. I did perform some searches for my problem, but unfortunately did not get any results for what I was looking for.

Thanks in advance for helping me!

regards,
Seemanta

Hi,
you have access to the port D on the Arduino with the command PORTD. You still have to set the io-pins as outputs, but then you can simply write fro instance

PORTD=B10101010;

to update all of the 8 pins with one command.
Eberhard

DDRD = 0xFF; // make pins 0 - 7 outputs
PORTD = byte; // byte is the 8 bits you want to output in parallel

This is a case where it’s useful to peruse the mega168 datasheet and understand how the microcontroller’s registers work. The above code will take 125 ns to execute (note that digitalWrite() on a single pin takes several microseconds).

  • Ben

Edit: Wow, posted at exactly the same time as Eberhard (all the way down to the same second)!

http://www.arduino.cc/en/Reference/PortManipulation There’s alot of info on that page about port manipulation…

/Jon

Thanks a lot for your response!! I am overwhelmed by your promptness (within 7 mins!!!)

regards,
Seemanta

Edit: Wow, posted at exactly the same time as Eberhard (all the way down to the same second)!

Lol, I hadn’t noticed the date in the quote tag was specified as a Unix time stamp. e…g. date=1214383436 :slight_smile:

–Phil.