stm32duino and DMA / ADC

Post here first, or if you can't find a relevant section!
Post Reply
baylf2000
Posts: 4
Joined: Thu Aug 24, 2023 1:01 am

stm32duino and DMA / ADC

Post by baylf2000 »

I'm using a couple of different Nucleo-H7 boards with stm32duino and I was hoping to find some information on using DMA that doesn't involve just trying to copy over the mess from cubemx.

Are there any libraries available, or other information that might help me get started?
Last edited by baylf2000 on Thu Aug 24, 2023 2:29 am, edited 1 time in total.
baylf2000
Posts: 4
Joined: Thu Aug 24, 2023 1:01 am

Re: stm32duino and DMA

Post by baylf2000 »

The closest thing I've found is over in Roger Clark's repo, called "STM32ADC." It looks to be exactly what I'm looking for, but it seems to be very specific to the F1 and F4, and I assume also requires Roger's core.

Is there anything like this for the H7 and stm32duino?

https://github.com/rogerclarkmelbourne/ ... s/STM32ADC
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: stm32duino and DMA / ADC

Post by MasterT »

What is the board?
stmduino, do you mean ST official plug-in installed over arduino IDE?
I haven't seen examples, except CubeMX
https://github.com/STMicroelectronics/S ... r/Projects
and
https://github.com/STMicroelectronics/S ... A_Transfer

I have adc running on nucleo-H743zi2, spend a lot of time copyng/pasting from Cube. I'd suggest to move gradually, have adc working first, than get yourself familiar with DMA, and first things you need a sketch that allows to read-modify internal registers under arduino IDE
baylf2000
Posts: 4
Joined: Thu Aug 24, 2023 1:01 am

Re: stm32duino and DMA / ADC

Post by baylf2000 »

Yes, sorry, I mean the official STM32 Arduino framework.

The Nucleo boards are the H743ZI2 and H723ZG.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32duino and DMA / ADC

Post by ag123 »

i messed with the F4xx series and H7 (e.g. h743) series, H7 is apparently quite a different chip in which the peripheral clocks and system clocks can practically be 'untied' from each other. Didn't dig further into that, but that H7 apparently has an advanced clocks structures, my guess is in part how it can achieve those very high system clocks, while keeping the peripherals running at significantly lower frequencies/speeds, and to an extent 'untied' from the system clock, so that the system clock can practically change speeds on the fly ( i think).

on 'roger's' (libmaple) core, there is the ADC lib and I actually tried something with stm32f103 and libmaple core
https://github.com/ag88/GirinoSTM32F103duino
https://github.com/ag88/GirinoSTM32F103 ... 2f103mm_v3
that CAdcMgr class can probably be reused in stm32f103 and (roger's) libmaple core, but that it is unlikely to work elsewhere.

for STM core, I remembered @fpiSTM made an example related to that
viewtopic.php?t=110
the difference in the implementations, is apparently that the hooks for DMA needs to be 'connected' into HAL i.e. call back the HAL codes.
HAL is 'not very well documented' except for its source codes, at one point I studied it a little and figured out 'approximately' how to get it to work, but didn't find much time to work those things. There are various comments in the HAL source codes to 'guide' you along, hence read those comments as you work them. google/bing search etc would also return some useful things about HAL, hence, do (re)search around.

using HAL makes it more likely that your code can go 'cross series' as it is part of the work of ST's HAL to achieve that.
Last edited by ag123 on Thu Aug 24, 2023 2:24 pm, edited 1 time in total.
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: stm32duino and DMA / ADC

Post by MasterT »

baylf2000 wrote: Thu Aug 24, 2023 12:27 pm Yes, sorry, I mean the official STM32 Arduino framework.

The Nucleo boards are the H743ZI2 and H723ZG.
If 16-bits resolution and high sampling rate required, than you need some mod on nucleo boards:
1. remove ethernet, all jumpers listed in UM2407 MB1364 06.2020

2. bring HSE clock to 8.33 MHz, STlink programmer has this option in upgrade mode. Consequently modify some arduino config files
referencing HSE as 8 MHz

3. remove Vref jumper (connected to Vdd) and activate internal Vref or use external Vref source

What is the application?
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32duino and DMA / ADC

Post by ag123 »

I think a lot of times 12 bits can reach those published rated rates on the spec sheets. But I seemed to have seen some mcus capable of doing 8 bits at faster speeds etc, e.g. in dual interleave, triple interleave or even quad interleave mode.
I've read something like the stm32f303, if you do quad interleave and 8 bits, it can probably push the boundary of 20 msps (i.e. 4x5 msps), that is pretty darn fast on an mcu, the bottleneck is usb (full speed) mainly for transferring that data 'out'. for 'oscilloscopes' it is then just limited to that sram 'sweep' for the data that it can capture.

i'm thinking of messing with FT232H
https://www.ftdichip.com/Support/Docume ... FT232H.pdf
which has some propietary high speeds transfer modes

of course some of the stm32s have a usb 2.0 high speed ULPI interface, which accordinly may work with USB3300 high speed transceiver from microchip
https://www.microchip.com/en-us/product/usb3300
, but I stumble over that 60 mhz 8 bit parallel bus speeds interfacing requirements, which I think I can't achieve anything close to that with 'dupont wires', I'm not sure if it is at all possible for 'hobby' projects. it is likely feasible if the mcu and the usb 2.0 high speed transceiver sits on a same PCB and well wired to ensure those speeds, but doublt 'loose wires' can do those things. And if there are issues, I'd probably have no tools to tell what's wrong at those 60 mhz, 480 mbps speeds.
baylf2000
Posts: 4
Joined: Thu Aug 24, 2023 1:01 am

Re: stm32duino and DMA / ADC

Post by baylf2000 »

:D
MasterT wrote: Thu Aug 24, 2023 2:21 pm If 16-bits resolution and high sampling rate required, than you need some mod on nucleo boards:
Can you explain why?
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: stm32duino and DMA / ADC

Post by MasterT »

baylf2000 wrote: Thu Aug 24, 2023 9:32 pm :D
MasterT wrote: Thu Aug 24, 2023 2:21 pm If 16-bits resolution and high sampling rate required, than you need some mod on nucleo boards:
Can you explain why?
1. Ethernet IC on nucleo-144 generates quite high voltage ripple, even ethernet is not activated. My measurements shows about 200 mV p-p on 5V rail when board power over E5V, slightly less on 3.3V rail.
2. Default freq. source was 8 MHz from stlink, derived from internal HSI (64 MHz RC oscillator). Jitter is so huge, that oscilloscope can't synchronize channel input with it. 8.33 is 25/3 - Crystall oscillator with excelent jitter & stability parameters
In summary, 12-bits noise free is the max w/o any board modification.
I did some comparison with nucleo-G474 (no mod. necessary, clock is good, no erhernet & on-board V-ref present), and find out that G474 has pretty much the same quality adc. 5 adc in one uCPU. Though only 12-bits
possiblehappy
Posts: 1
Joined: Wed Nov 15, 2023 8:16 am

Re: stm32duino and DMA

Post by possiblehappy »

baylf2000 wrote: Thu Aug 24, 2023 1:19 am The closest thing I've found is over in Roger Clark's repo, called "STM32ADC." It looks to be exactly what I'm looking for, but it seems to be very specific to the F1 and F4, and I assume also requires Roger's core.

Is there anything like this for the H7 and stm32duino?

https://github.com/rogerclarkmelbourne/ ... s/STM32ADC
In accordance with your needs for data transport, configure the DMA channel. This involves indicating the transmission mode, data size, and source and destination addresses. If during the DMA transfer you need to convert or manipulate data, make sure you implement the appropriate logic or functions to fulfill these tasks.
Post Reply

Return to “General discussion”