dac in 8 bits mode

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

dac in 8 bits mode

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

Hello,

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
     break;
 #if STM32_DAC_DUAL_MODE == TRUE
   case DAC_DHRM_12BIT_RIGHT_DUAL:


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)

Alexandre

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: dac in 8 bits mode

Postby Giovanni » Sat Feb 13, 2021 10:23 am

bump


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 67 guests