2 of 2 people found this helpful
It should be the same, however the pins would be the Port D pins for bits 4-7, which won't necessarily be labelled D4-7 on the Arduino. For example, the port D bit 4 is labelled D20 (see the red arrows in the diagram below). So setting Port D bits 4-7 would actually set D20, D21, AREF .
I have not got an Arduino Every so this is just based on what I'd expect to occur though.
Thank you Shabaz, it worked as you described!.
It was a bummer for me that the pins are all spread and couldn't managed to find a quantity enough grouped under the same register for my intended use.
Thanks a lot for your help.
Can someone illustrate -or- point me in the right direction on how to manipulate port registers in the Nano Every (ATmega4809)?. - I'm using the Arduino IDE
The port manipulation described here for the ATmega328p/ATmega168 works as follows and works well for me in the Arduino Pro Mini and ATmega48;
DDRD |= B11110000; // sets ATmega digital pins 7 to 4 as Outputs PORTD = B10010000; // sets digital pins 7,4 HIGH
When I try the equivalent with the Nano Every (ATmega4809) it seems the pin mapping is completely different
VPORTD.DIR |= B11110000; VPORTD.OUT = B11110000;
I'm using bit-wise operations as my plan is to replicate the same in the Nano Every without emulation -if possible- so I can manipulate many digital/analog pins at once with one instruction (avoiding having to do it for each GPIO at a time)