2021-04-07 01:51 AM
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:
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
2021-04-10 02:06 PM
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.