Skip to content

Commit 4429b05

Browse files
committed
DM: fix samd21 dac resolution
1 parent 0a24711 commit 4429b05

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cores/arduino/wiring_analog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int _writeResolution = 12;
3232
static int _dacResolution = 12;
3333
#else
3434
static int _writeResolution = 8;
35-
static int _dacResolution = 8;
35+
static int _dacResolution = 10;
3636
#endif
3737

3838

@@ -368,9 +368,10 @@ void analogWrite(uint32_t pin, uint32_t value)
368368
if (pin == PIN_A0) { // Only 1 DAC on A0 (PA02)
369369
#endif
370370

371-
value = mapResolution(value, _writeResolution, _dacResolution);
371+
value = mapResolution(value, _writeResolution, _dacResolution);
372372

373373
#if defined(__SAMD51__)
374+
374375
uint8_t channel = (pin == PIN_A0 ? 0 : 1);
375376

376377
pinPeripheral(pin, PIO_ANALOG);
@@ -423,7 +424,6 @@ void analogWrite(uint32_t pin, uint32_t value)
423424

424425

425426
#else
426-
value = mapResolution(value, _dacResolution, 10);
427427
syncDAC();
428428
DAC->DATA.reg = value & 0x3FF; // DAC on 10 bits.
429429
syncDAC();

0 commit comments

Comments
 (0)