Writingto digital pins a byte at a time

I have a Mega 2560 board and would like to use the digital pins from 22 to 53. It appears that they can only be programmed individually through the Arduino software. Is there no way to feed this pins a byte at a time? After all they are connected to 8-bit registers. Writing a byte at a time would surely be much faster than writing to each one at a time.

It appears that they can only be programmed individually through the Arduino software.

Direct Port Manipulation (a search term for you) can be used, but it is not portable.

Writing a byte at a time would surely be much faster than writing to each one at a time.

Yes, but does speed really matter?

Thanks gents.

Speed not an issue, it just seems daft to have a system based on 8 bit registers (ie capable of parallel data movement) but only program it serially.

It's not daft at all: I'd wager that 90% of the time one only wants to write to a few pins at the same time, and then they may well be on different ports.... switch an LED here, a motor there.

If it happens that you have a port's worth of data ready, then yes of course do it that way.

Apart from speed, there may be cases when for reasons to do with the outside world, a bunch of pins need actioning at the same time (as opposed to separate, albeit very close, instances in time)- then writing to a port would also make sense.

If you look at devices that take parallel data/address you will find that they have at least 1 if not 2 or 3 extra lines to provide control. So you setup the data on the parallel data bus and then toggle the control line(s) to execute the operation.

Mark

Hi All,
I’m almost with Microchip here, coming from a PIC background and was used to writing to a port 8 bits at a time. The good bits! robot control %00000101 the 2 set bits drive the motors forwards, do a shift < and %00001010 sends them backwards, etc. from one port you can control sound, LED inducators, sensors and motors…

But I like the Arduino better, still fighting with C a bit and lots to learn, but writing to one pin at a time don’t seem to be a problem and the fact that you don’t know what port it is! doe’nt seem to matter either. (Yes I know you can look up the various port, pinouts, etc).

Regards

Mel.