[riot-notifications] [RIOT-OS/RIOT] cpu/sam0_common: implement periph/dac (#13965)

benpicco notifications at github.com
Fri May 1 16:49:38 CEST 2020

@benpicco commented on this pull request.

> + * @author      Benjamin Valentin <benpicco at beuth-hochschule.de>
+ *
+ * @}
+ */
+#include "cpu.h"
+#include "periph/dac.h"
+#include "periph/gpio.h"
+#include "byteorder.h"
+#ifndef DAC_CLOCK
+#define DAC_VAL(in) (in >> (16 - DAC_RES_BITS))

The problem is that the DAC API assumes a full 16-bit input value.
So setting a value > 1023 will make the DAC overflow back to zero - you can observe this with `tests/periph_dac`.

On other DACs (e.g. lpc2387) you write the full 16-bit value but this being a 10 bit DAC, the lower (least significant) 6 bytes are ignored.
Here the most significant bytes would be ignored, which leads to wrong output values.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200501/a0f4118e/attachment.htm>

More information about the notifications mailing list