2022-03-28 06:29 AM
Hello,
Can you help me to use the DMAMUX in the STM32G474 microcontroller?
How can I program the uC to make TIM2_CH1 sends a DMA request when CC. I have found this in the reference manual but I can't undesrtand which channel of the DMA is involved. Thanks for the clarification
Solved! Go to Solution.
2022-05-06 03:41 AM
Problem is, that there's no good documented way for this wait. ST published this as errata for older STM32 families, and some of the proposed workarounds are known to not work (and ST does not care, as usually). ST's "libraries" are usually inefficient enough so that timing issues such as these simply never come up.
You can try to insert a couple of NOPs, or dummy reads. A bulletproof solution would be to loop writing and reading back one DMAMUX register utnil it reads back the value written.
What I do is, that I enable all peripheral clocks for peripherals used in the given application early in the program, starting with GPIOs' clocks; then I initialize all GPIOs, then I do any other peripheral initialization. I don't subscribe to the "everything related to given peripheral should be changed at one place" notion (related to my reluctance to use any "abstraction" in microcontrollers).
JW
2022-05-06 03:48 AM
thanks @Community member
Now with some dummy lines between the clock activation and the DMAMUX rmapping the registers change as I wanted.
2022-05-06 07:50 AM
Hi @Community member and @TDK,
In order to use the DMAMUX properly, did I forget anything?
For what concerns the DMAMUX I just enabled its clock and set the REQ_ID but the DMA transfer does not work in my code. Do I forget anything in the settings of the DMAMUX?
2022-05-07 01:14 AM
Read out and check/post TIM2, DMAMUX and DMA registers content.
JW
2022-05-10 12:40 AM
Hi @Community member
I would like to have TIM2_CH1 and TIM2_CH2 to trigger a DMA transfer, from memory to SPI1 and SPI2 respectively, when the timer has output compare events.
Basically when looking at the SPI1 and SPI2 pins I can see the SPI clock but I do not see the MOSI output. Moreover if I change the CCR1 and CCR2 values of TIM2 I can't see the SPI clock busrts rate changing.
So, I guess there are two problems: one regarding the DMA trasnfer (maybe something wrong in the DMAMUX?) and another one in the registers output compare channels.
Here the registers (I am using Nucleo G474RE)
2022-05-10 01:32 AM
Binary view of values is not very useful, especially if it cuts the end of the numbers. Switch to hexadecimal.
When I write "check/post registers", I mostly mean "check, and if you don't see anything wrong, post".
What is the timer period and the SPI clock rate?
If you don't see output on MOSI, check/post also the GPIO setting of MOSI pin.
JW
2022-05-10 01:41 AM
Sorry @Community member
here the values shown correctly
2022-05-10 03:59 AM
What is the timer period and the SPI clock rate?
These are quite high addresses (in 'G474, if I am correct, RAM ends in the CCMRAM alias, at 0x2001FFFF). How exactly do you set them? Aren't those arrays local variables, i.e. located at stack? What is their content?
JW
2022-05-10 04:06 AM
OK so you have SPIx_CR1.BIDIMODE set, and BIDIOE clear, which means you are in halfduplex, Rx mode, that's why clocks are output continuously, regardless of DMA.
Are you sure you want to use halfduplex SPI? It's rather tricky.
Get SPI working first, without DMA, with software polling.
JW
2022-05-10 07:11 AM
Hi @Community member
As you pointed out, there was the error about the SPI MODE half duplex. It was a typo that I did when I was trying the cube MX enviroment and I erronously set that SPI mode.
Eventually the FW regarding the TIM2, the DMA and the SPI now works correctly.
Thanks a lot for your help