This works on an Uno:
uint8_t x = PINB;
What is the equivalent for the Uno WiFi Rev 2 (ATmega4809 microcontroller)?
PINB doesn't seem to be defined.
This works on an Uno:
uint8_t x = PINB;
What is the equivalent for the Uno WiFi Rev 2 (ATmega4809 microcontroller)?
PINB doesn't seem to be defined.
The ATmega4809 have ports A, C, D and F. You don't have them in one row on the header as pin 8 to 13 as you have PINB on the UNO.
I'm fine with reading out of multiple ports and all the bit manipulation funtions but what is the low level read command to get a port on the Uno WiFi Rev 2?
what is the low level read command to get a port on the Uno WiFi Rev 2?
x = VPORTB.IN;
Note that the board-level pins are quite scrambled. While an Uno can read pins 0..7 in order as PORTD, reading pins 0..7 on an Uno WiFi 2 requires reading 4 separate ports and fiddling with bits.
The Arduino core for Mega0 chips has "Port emulation", where if you enable it and say x = PINB;
, the multiple reads and bit twiddling will all be done for you. But if your goal was speed, it's PROBABLY not the way you to go.
Great! That's what I was looking for. Can you give me a pointer to enabling Port Emulation as well?
An option "Registers optimization" shows up in the "Tools" menu after selecting a Board type that has the 4809.
I believe "Emulation On" is the default.
If you try to use it, you'll get the warning (which may scroll past unnoticed):
/Applications/Arduino-1.8.13.app/Contents/Java/portable/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/UNO_compat.cpp:20:2: warning: #warning "ATMEGA328 registers emulation is enabled. You may encounter some speed issue. Please consider to disable it in the Tools menu" [-Wcpp]
#warning "ATMEGA328 registers emulation is enabled. You may encounter some speed issue. Please consider to disable it in the Tools menu"
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.