Conflict between PF2|3 and PA2|3 (A4 and A5) on Arduino Nano Every?

In the electrical diagram (and also in the EAGLE gerber files) the A4/SCL and A4/SDA pins are each connected to two pins of the micro, namely A4 with PF02 and PA02, and A5 with PF03 and PA03. This seems very strange, perhaps a design error?
Regardless, I wanted to use A5 as a digital output; in the setup I declared A5 as output with the pinMode() function and everything works as expected: digitalWrite() does its duty. However, since the digitalWrite() function is very slow, I replaced it with the PORTF.OUTSET and PORTF.OUTCLR functions, and again everything works as it should; but if instead of using port F I turn to port A, pin A5 always remains at 0. How do you explain all this?
Furthermore, I observe that in Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809\pins_arduino.h it seems that A5 is connected only to PF3 (in the line #define PIN_A5 (19) // PF3 / AIN13), while in the datasheet (at point 6 - connector pinout) it is stated that A5 is connected to PA3. There is clearly some confusion.
Since I first tried to raise A5 with the command PORTA.OUTSET=PIN3_bm, but pin A5 did not raise, have I created a conflict (potentially destructive for the gates in question) with PF3?
What inhibits port A when port F is active?
Thanks to anyone who can clarify.

Indeed, outputs PA2 and PF2 of the ATmega4809 are connected to the same pin of the Nano Every Board, and so are PA3 and PF3, effectively short-circuits.

I expect that when using digitalRead, digitalWrite, analogRead and analogWrite the Arduino IDE will not cause these outputs to destroy each other (I haven’t tested that, but I’ve seen bits of their inner workings). But when you address the port-registers directly, there will be no protection whatsoever. You’ll need to watch out yourself.

It might be a design error, or there might be some logic thinking behind it (but don’t ask me what).

1 Like

I’ve been digging a bit deeper. Using digitalRead, digitalWrite, analogRead and analogWrite the Arduino IDE will address PF2 and PF3. Using Wire (TWI aka I2C) Arduino will address PA2 and PA3.

MCUdude shows more possibilities available at the pins of the Nano Every.

Interesting! so it is not a design error, but a way of using a single pin for two alternative functions. However, the pinout reported in the datasheet is, if not incorrect, at least misleading. The pinout reported in MCUdude/MegaCoreX is certainly more complete (I had used MegaCoreX a couple of months ago, but I hadn't noticed this detail).
Even the risk of conflict by directly accessing the registers seems to me to be reconsidered, because when I initially raised PA3 (misled by the datasheet) I saw no signs of conflict on A5 (I was looking at it with the oscilloscope), probably because I2C was disabled ( it is by default). it is clear that if one enables I2C he will not use A4 and A5 as generic IO.
Thanks to stitech for the investigation

Within a PORT-instance there is some protection, if a peripherial (in this case TWI) ‘takes over’ the port pin, the normal port registers become irrelevant.
Of course this doesn’t resolve the conflict between Port A and Port F.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.