Skip to main content
Visitor II
April 5, 2023
Solved

Can peripheral-to-memory or memory-to-memory DMA be transfers be configured to substitute for lack of peripheral-to-peripheral features in the Cube toolchain?

  • April 5, 2023
  • 1 reply
  • 2784 views

I need to load the TIM1 CCR registers into the DAC1 outputs on an STML432KC. I have this working with the line DAC1->DHR12R1 = TIM1->CCRx executing in a loop. I'd like to substitute with DMA.

Others have suggested that I can do this with the available DMA features and supplying the the necessary register addresses. I gave it a shot and couldn't make it work. However, this is my first STM32 project, and I'm new to the toolchain.

Is this approach really viable?

    This topic has been closed for replies.
    Best answer by KHarb.1

    Changing CPAR and CMAR registers after DMA init does what's needed. As long as they reconcile with the direction bit, I'm not sure it matters which address goes into CPAR and CMAR. 

    1 reply

    Graduate II
    April 6, 2023

    >>Is this approach really viable?

    So you're going to replace a transfer that's triggered with one that basically runs in saturation?

    You need to determine which DMA resource is triggered by TIM1 CCx, or find a different TIM.

    The Reference Manual should show the relationship. And the DMA unit that's triggered by the TIM should be able to read any of that TIM peripherals registers as a Peripheral Source.

    KHarb.1Author
    Visitor II
    April 6, 2023

    The DMA is intended to be triggered. There are two signals with the same frequency with varying phase offset. One signal clears the timer and the other registers the input capture to yield the relative phase. Sending the capture register to the DAC yields an analog version of the varying phase offset. Either signal can be used as the DMA trigger.

    Regarding DMA resources: I let Cube set that up by setting up DMA options within the DAC config menus. I then called HAL_DAC_Start_DMA and give it the the address of the capture register. Nothing appeared to happen. Since Cube doesn't know the destination address during config, it might not know it if linking DMA to TIM1 is somehow not allowed.