Skip to content

Remove the DAC requirement that A0 must be PA02 #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cores/arduino/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ uint32_t analogRead(uint32_t pin)

pinPeripheral(pin, PIO_ANALOG);

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

if (pin != PIN_A0) { // Only 1 DAC on A0 (PA02)
if ((pinDesc.ulADCChannelNumber != ADC_Channel0) && (pinDesc.ulADCChannelNumber != DAC_Channel0)) { // Only 1 DAC on AIN0 / PA02
return;
}

Expand Down