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-03-28 07:20 AM
You can use any channel you want. You need to set up the MUX such that that channel's input is tied to the request that you want.
For example, if you want to use DMA1 channel 1, set DMAREQ_ID=56 in DMAMUX_C0CR.
If you want to use DMA2 channel 8, use DMAMUX_C15CR instead.
(Note that DMA channel indices are 1-based while DMAMUX indices are 0-based.)
2022-03-28 07:57 AM
Hi @TDK
Now I see, The register I write sets the DMA channel: DMAMUX_C0CR refers to DMA1channel1, DMAMUX_C1CR refers to DMA1channel2, and so forth.
Thanks
2022-03-28 08:00 AM
Can the same peripheral (e.g. tim2_ch1) send DMA request to two different DMA channel?
Can I write the same DMAREQ_ID in more than one dedicated register?
2022-03-28 08:06 AM
No.
2022-04-27 03:41 AM
Hi @TDK
Sorry to bother you again..
But the expression DMAMUX -> C0CR = 56; does not work because of a syntax error.
I think it is beacuse the CMSIS STM32G474xx Device Peripheral Access Layer Header File lacks of some definitions. Can you help me to suitably code that DMAREQ_ID=56 in DMAMUX_C0CR ?
Thanks a lot
2022-04-27 04:52 AM
ST is not very consistent in keeping RM nomenclature en sync with symbols in CMSIS-mandated device headers. As ST declines to provide normal examples, sometimes you may be required to have a look at the header yourself:
i.e. you'd use DMAMUX1_Channel0->CCR = 56;
JW
2022-05-04 06:57 AM
Hi,
@Community member
it seems that the DMAMUX1_Channel0->CCR = 56 does not have syntax error but the DMAMUX register does not change when debugging my code. Do you think there is an error yet?
2022-05-05 08:21 AM
And when you stop execution (place breakpoint) somewhere after those two lines, can you change the DMAMUX register values in the debugger?
I bet you can't as you probably did not enable DMAMUX clock in RCC:
JW
2022-05-06 03:25 AM
Hi @Community member
yes I forgot to enable the DMAMUX clock in the RCC.
As you explained, now I can edit the register in the debugger and that works.
However with my code (relevant part reported below) the registers still do not change.
Do you have any idea about this latter issue?
void DMA1_Init(void){
// Enable the DMA Clock
RCC-> AHB1ENR |= (1<<0)|(1<<2); // Enable DMA1 and DMAMUX1 Clock
// DMAMUX mapping:
//DMAMUX1_Channel0 (connected to DMA1_Channel1) receives a request form TIM2_Ch1.
DMAMUX1_Channel0 -> CCR = 56;
// DMAMUX1_Channel1 (connected to DMA1_Channel2) receives a request form TIM2_Ch2
DMAMUX1_Channel1 -> CCR=57;
}
int main(void)
{
DMA1_Init();
}