cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 DFSDM+ADC - bugs in CubeMX/HAL/generated code?

TDJ
Senior III

Using the latest CubeMX 6.2.1 and STM32H7A3 I try to accomplish, one would think, a very simple task: filter data from ADCs using DFSDM.

Objective: capture N samples (conversions) on demand (e.g. button press) from several ADC channels, smooth edges with DFSDM and analyze - just like oscilloscope 'single run' or ADC Conversion Data Management = DMA One Shot Mode but for DFSDM.

After several evenings of trying and failing I found configuration that may work. I call:

HAL_DFSDM_FilterRegularStart_DMA(...);

HAL_ADC_Start(...);

and HAL_DFSDM_FilterRegConvCpltCallback() gets called repeatedly, the buffer seems to contain some data.

Problems:

  1. On DMA callback the data in the buffer is exactly the same at least three times in a row. It seems that DMA does not actually copy new data. It is next to impossible that 8 active ADC channels produce exactly same conversion results three times in a row (FOSR=1, IOSR=1)
  2. DFSDM+ADC concept is unclear at best. RM0455 33.4.6 (Parallel data inputs) covers the whole scenario in exactly three, rather cryptic sentences. Are data from each ADC channel processed separately? What happens if more than 8 ADC channels are active? I found no answer yet.
  3. According to HAL API docs, after calling HAL_DFSDM_FilterRegularStart_DMA(...) every 32b buffer word should contain DFSDM channel number in LSB but it does not. I was hoping to identify source ADC channel this way but maybe it is not how it works.
  4. I am unable to restart conversion if DMA is in "Normal" mode. Subsequent attempt to start it calling HAL_DFSDM_FilterRegularStart_DMA() returns an error. An attempt to stop conversion first using HAL_DFSDM_FilterRegularStop_DMA() yields HAL error as well.
  5. I am unable to stop conversion if DMA is in "Circular" mode. An attempt to stop it using HAL_DFSDM_FilterRegularStop_DMA() causes HAL error. I am convinced it is a bug.

Please advise.

In general, there are no DFSDM working examples or even code snippets available. Examples are mentioned in ST YouTube presentations and AN4990 but they are nowhere to be found. Not a single one. The only supposedly complete ST example I found was EVALSTPM-3PHISO firmware (UM2847, DB4332) but is it largely undocumented, no schema/PCB, it requires commercial IAR environment and parts of it are written in assembler. It seems like no decision has been made whether it should be a commercial solution or it should serve educational purpose.

CubeMX 6.2.1, STM32Cube FW_H7 V1.9.0

1 REPLY 1
TDJ
Senior III

I found problem 1 solutions: DCache has to be invalidated before accessing the DFSDM filter buffer, unlike ADC (?) buffer has to be 32b aligned.

Problem 5 identified: unlike ADC, it seems DFSDM cannot be stopped from within HAL_DFSDM_FilterRegConvCpltCallback(). I still do not know how to stop DFSDM after arbitrary number of samples/conversions or buffers is collected without (i.e.) constantly checking some flag in the main loop and stopping DFSDM from there - probably a poor solution but it is a solution if only the main loop runs fast enough. Otherwise, I think some timer could be used but it is still a poor solution. Function analogous to ADC "DMA One Shot Mode" would be appreciated.

Problems 2, 3, 4 remain unsolved.