ADCv3 fixes Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

ADCv3 fixes

Postby FXCoder » Fri Jul 24, 2020 3:07 pm

Hi.
There are a few things in ADCv3 that can be updated I think.
1. The Error and AWDG interrupts are enabled when there is no callback.
2. AWD2 and AWD3 are not catered for in config.
--
Bob

Code: Select all


Index: hal_adc_lld.c
===================================================================
--- hal_adc_lld.c   (revision 13789)
+++ hal_adc_lld.c   (working copy)
@@ -847,11 +847,18 @@
   dmaStreamSetMode(adcp->dmastp, dmamode);
   dmaStreamEnable(adcp->dmastp);
 
-  /* ADC setup, if it is defined a callback for the analog watch dog then it
-     is enabled.*/
+  /* Clear any interrupts. If an error callback is defined then enable
+     overflow and analog watchdog interrupts. */
   adcp->adcm->ISR   = adcp->adcm->ISR;
-  adcp->adcm->IER   = ADC_IER_OVRIE | ADC_IER_AWD1IE;
-  adcp->adcm->TR1   = grpp->tr1;
+  if (grpp->error_cb != NULL) {
+    adcp->adcm->IER   = ADC_IER_OVRIE | ADC_IER_AWD1IE
+                                      | ADC_IER_AWD2IE
+                                      | ADC_IER_AWD3IE;
+    adcp->adcm->TR1   = grpp->tr1;
+    adcp->adcm->TR2   = grpp->tr2;
+    adcp->adcm->TR3   = grpp->tr3;
+  }
+
 #if STM32_ADC_DUAL_MODE
 
   /* Configuring the CCR register with the user-specified settings
Index: hal_adc_lld.h
===================================================================
--- hal_adc_lld.h   (revision 13789)
+++ hal_adc_lld.h   (working copy)
@@ -851,10 +851,14 @@
            specified in continuous mode or if the buffer depth is           \
            greater than one.*/                                              \
   uint32_t                  cfgr;                                           \
-  /* ADC CFGR2 register initialization data.*/                                              \
+  /* ADC CFGR2 register initialization data.*/                              \
   uint32_t                  cfgr2;                                          \
   /* ADC TR1 register initialization data.*/                                \
   uint32_t                  tr1;                                            \
+  /* ADC TR2 register initialization data.*/                                \
+  uint32_t                  tr2;                                            \
+  /* ADC TR3 register initialization data.*/                                \
+  uint32_t                  tr3;                                            \
   /* ADC CCR register initialization data.                                  \
      NOTE: Put this field to zero if not using oversampling.*/              \
   uint32_t                  ccr;                                            \
@@ -873,6 +877,8 @@
   uint32_t                  cfgr;                                           \
   uint32_t                  cfgr2;                                          \
   uint32_t                  tr1;                                            \
+  uint32_t                  tr2;                                            \
+  uint32_t                  tr3;                                            \
   uint32_t                  smpr[2];                                        \
   uint32_t                  sqr[4]
 #endif /* STM32_ADC_DUAL_MODE == FALSE */
@@ -882,6 +888,8 @@
 #define adc_lld_configuration_group_fields                                  \
   uint32_t                  cfgr;                                           \
   uint32_t                  tr1;                                            \
+  uint32_t                  tr2;                                            \
+  uint32_t                  tr3;                                            \
   uint32_t                  ccr;                                            \
   uint32_t                  smpr[2];                                        \
   uint32_t                  sqr[4];                                         \
@@ -891,6 +899,8 @@
 #define adc_lld_configuration_group_fields                                  \
   uint32_t                  cfgr;                                           \
   uint32_t                  tr1;                                            \
+  uint32_t                  tr2;                                            \
+  uint32_t                  tr3;                                            \
   uint32_t                  smpr[2];                                        \
   uint32_t                  sqr[4]
 #endif /* STM32_ADC_DUAL_MODE == FALSE */

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: ADCv3 fixes

Postby Giovanni » Tue Jul 28, 2020 7:50 pm

Hi,

I am looking into this, the patch is not sufficient, AWD2 and AWD3 also have configuration registers to be initialized, I am adding those to the configuration structure.

Giovanni

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: ADCv3 fixes

Postby Giovanni » Thu Jul 30, 2020 9:28 am

Hi,

I committed changes to trunk, could you check if it is OK? I added support for AWD2CR and AWD3CR registers to the conversion group structure. I could only test-compile it.

Giovanni

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: ADCv3 fixes  Topic is solved

Postby FXCoder » Sat Aug 01, 2020 2:21 am

Thanks.
Will do some testing next week.
--
Bob


Return to “Bug Reports”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 42 guests