Go Down

Topic: Is there another way to do a DigitalWrite? (Read 1 time) previous topic - next topic

dhenry

Quote
if there is a way to just write a
byte of data to set all output levels at once.


Yes, if those pins are on the same port.

CrossRoads

Commamds like

PORTD = some_value;
PORTC = some_value;
PORTB = some_value;

writes all the bits at the same time, if you have used pinMode ahead of that to set the pins as OUTPUT.
Not all port2 have 8 bit on an Uno.
And some might be in use as another function, such as Rx/Tx. So you have to pay a little attention when doing that.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

irethedo

I have another bit of code that is getting a compile error on the following line:

        PORTA = (PORTA ^ B00000001);

with a 'PORTA' was not declared in  this scope ' error.

I am using an atmel chip with the Uno bootloader and if I change the board type to a mega, it compiles without error.

How can I set this up to load on my Uno without an error?

thanks

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

retrolefty


I have another bit of code that is getting a compile error on the following line:

        PORTA = (PORTA ^ B00000001);

with a 'PORTA' was not declared in  this scope ' error.

I am using an atmel chip with the Uno bootloader and if I change the board type to a mega, it compiles without error.

How can I set this up to load on my Uno without an error?

thanks



Some arduino boards don't have a PORTA like a Uno, some do like a mega. You might want to review this document to understand the arduino pins Vs port assignments for the basic Uno and Mega boards.
https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Lefty

Go Up