dac in 8 bits mode

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
Posts: 304
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 28 times
Been thanked: 37 times

dac in 8 bits mode

Postby alex31 » Mon Sep 21, 2020 8:15 pm


I am using ChibiOS 20.3, stm32F4, and need to use DAC in 8 bits mode. Although is work well in 12 bits mode, half buffer callback is called twice as it should in DAC_DHRM_8BIT_RIGHT mode, no dual channel, only one channel used.

The code of the hal is complex because there is conditionnal compilation for all the possible mode (dual mode or not, many channel or not), but in my case, i resolved my bug with that fix :

Code: Select all

diff --git a/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.c b/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.c
index b4180d36c..91be17efd 100644
--- a/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.c
+++ b/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.c
@@ -672,7 +672,9 @@ void dac_lld_start_conversion(DACDriver *dacp) {
     /* In this mode the size of the buffer is halved because two samples
        packed in a single dacsample_t element.*/
-    n = (n + 1) / 2;
+    /* following line commented out to avoid callback called after ^M
+       quart buffer instead half buffer */^M
+    /* n = (n + 1) / 2;*/^M

Fix is given just as indication since it does not take into account all the other mode (dual, or DAC with more than 2 channels)


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 4 guests