File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,8 @@ uint32_t analogRead(uint32_t pin)
135
135
136
136
pinPeripheral (pin , PIO_ANALOG );
137
137
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 )) {
139
140
syncDAC ();
140
141
DAC -> CTRLA .bit .ENABLE = 0x00 ; // Disable DAC
141
142
//DAC->CTRLB.bit.EOEN = 0x00; // The DAC output is turned off.
@@ -196,7 +197,7 @@ void analogWrite(uint32_t pin, uint32_t value)
196
197
{
197
198
// DAC handling code
198
199
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
200
201
return ;
201
202
}
202
203
You can’t perform that action at this time.
0 commit comments