Skip to content

Commit 8ed4d1f

Browse files
Roy, ElizabethRoy, Elizabeth
authored andcommitted
Added check for A4 & A5 in analogWrite because it works as a digitalWrite for non-PWM capable pins
1 parent 4950f4f commit 8ed4d1f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cores/arduino/wiring_analog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ void analogWrite(uint8_t pin, int val)
125125
/* Special check for SPI_SS double bonded pin -- no action if SPI is active
126126
(Using Slave Select Disable as indicator of SPI activity) */
127127
if((pin == 10) && (SPI0.CTRLB & SPI_SSD_bm)) return;
128+
129+
/* Check if TWI is operating on double bonded pin (Master Enable is high
130+
in both Master and Slave mode for bus error detection, so this can
131+
indicate an active state for Wire) */
132+
if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return;
128133

129134
// We need to make sure the PWM output is enabled for those pins
130135
// that support it, as we turn it off when digitally reading or

0 commit comments

Comments
 (0)