Skip to content

Commit 6cc9bc7

Browse files
committed
Enabling PWM on pins A1/A2.
Pins A1/A2 uses TC4 to generate PWM, the same used in Servo library, so both cannot work together.
1 parent e607d35 commit 6cc9bc7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cores/arduino/wiring_analog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ uint32_t analogRead( uint32_t ulPin )
145145
ulPin += A0 ;
146146
}
147147

148-
pinPeripheral(ulPin, g_APinDescription[ulPin].ulPinType);
148+
pinPeripheral(ulPin, PIO_ANALOG);
149149

150150
if (ulPin == A0) // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
151151
{

variants/arduino_zero/variant.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ const PinDescription g_APinDescription[]=
139139
// 14..19 - Analog pins
140140
// --------------------
141141
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[0]
142-
{ PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // ADC/AIN[2]
143-
{ PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // ADC/AIN[3]
144-
{ PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ADC/AIN[4]
145-
{ PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ADC/AIN[5]
146-
{ PORTB, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel10, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[10]
142+
{ PORTB, 8, PIO_TIMER, (PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel2, PWM4_CH0, TC4_CH0, EXTERNAL_INT_8 }, // ADC/AIN[2]
143+
{ PORTB, 9, PIO_TIMER, (PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel3, PWM4_CH1, TC4_CH1, EXTERNAL_INT_9 }, // ADC/AIN[3]
144+
{ PORTA, 4, PIO_ANALOG, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ADC/AIN[4]
145+
{ PORTA, 5, PIO_ANALOG, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ADC/AIN[5]
146+
{ PORTB, 2, PIO_ANALOG, 0, ADC_Channel10, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[10]
147147

148148
// 20..21 I2C pins (SDA/SCL and also EDBG:SDA/SCL)
149149
// ----------------------

0 commit comments

Comments
 (0)