Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 253e40e

Browse filesBrowse files
GabrielNotmancmaglie
authored andcommitted
Removes the requirement that the DAC is on A0 (which requires that A0 uses PA02)
1 parent 9ac80d9 commit 253e40e
Copy full SHA for 253e40e

File tree

1 file changed

+3
-2
lines changed
Filter options

1 file changed

+3
-2
lines changed

‎cores/arduino/wiring_analog.c

Copy file name to clipboardExpand all lines: cores/arduino/wiring_analog.c
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ uint32_t analogRead(uint32_t pin)
135135

136136
pinPeripheral(pin, PIO_ANALOG);
137137

138-
if (pin == A0) { // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
138+
// Disable DAC, if analogWrite() was used previously to enable the DAC
139+
if ((g_APinDescription[pin].ulADCChannelNumber == ADC_Channel0) || (g_APinDescription[pin].ulADCChannelNumber == DAC_Channel0)) {
139140
syncDAC();
140141
DAC->CTRLA.bit.ENABLE = 0x00; // Disable DAC
141142
//DAC->CTRLB.bit.EOEN = 0x00; // The DAC output is turned off.
@@ -196,7 +197,7 @@ void analogWrite(uint32_t pin, uint32_t value)
196197
{
197198
// DAC handling code
198199

199-
if (pin != PIN_A0) { // Only 1 DAC on A0 (PA02)
200+
if ((pinDesc.ulADCChannelNumber != ADC_Channel0) && (pinDesc.ulADCChannelNumber != DAC_Channel0)) { // Only 1 DAC on AIN0 / PA02
200201
return;
201202
}
202203

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.