cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F334: HRTIM DMA Transfer error when send to CMP1xR register

OGhis
Associate III

I try to modulate a sinus signal with the PWM of the HRTIM.

Therefore i had used a table of 16 points, the PWM freq. is 640Khz and on the PWM output (TA1 of timer A).

After a RC filter i becomes a sinus signal of 40KHz.

The DMA send on every TA1 set, the new value to the compare register CMP1AR.

I have config the HRTIM with HAL_HRTIM_WaveformTimerConfig as follow

pTimerCfg.DMARequests = HRTIM_TIM_DMA_CMP1; 
  pTimerCfg.DMASrcAddress = (uint32_t)&sinustable[0];
  pTimerCfg.DMADstAddress = (uint32_t)&(hhrtim1.Instance->sTimerxRegs[HRTIM_TIMERID_TIMER_A].CMP1xR);
  //pTimerCfg.DMADstAddress = (uint32_t)&((CRC)->INIT);
  pTimerCfg.DMASize = PWM_SAMPLES;

When i run my code, i become from the HAL_HRTIM_ErrorCallback a message.

The error was a "Transfer Error Interrupt management" , ==> DMA_IT_TE was set.

I have try to change the DMA destination address to test if the DMA works:

pTimerCfg.DMADstAddress = (uint32_t)&((CRC)->INIT);

I can seen that the DMA works correct and that CRC->INIT was update with a value of my sinus table.

So far so good i say, the DMA works in the HRTIM.

When i set the 'PREEN' (Preload enable) bit in the TIMACR register to '1', i become no error more from the HAL_HRTIM_ErrorCallback.

The same issue is that the CMP1xR isn't updated with the DMA.

My question is how we can update the PWM compare register with the DMA?

See also source code and CubeMx project.

"Call the MyMain() from main()"

ps: the same principle i had used with the TIMER1 module, everything works fine but i had not the correct resolution. Therefore i will use now the HRTIM.

3 REPLIES 3
TSchi.3
Associate

Hey,

i have almost the same Problem. I tried to compare my settings with yours.

And i think some settings are missing am i right?

Can you provide the rest of the code pls?

I need the HRTIM to run and since a few days i have no Idea how to do it correctly.

best regards

Tobi

vincenthamp9
Associate III

Rather late reply, but since this topic was the very first google search result for "HRTIM DMA" for me I thought I should answer anyhow.

I ran in the same problem trying to update the period register of HRTIM1. Since I couldn't figure out what's wrong with my setup I went ahead and tried using another timer I'm already familiar with from other devices and combine it with DMA. So I picked TIM1 and tried to update it's channel 1 through DMA and... nothing.

This got me curious. So I started looking at material from ST and found this page here:

https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices

The very first bullet point explains how the H7 memory layout and the internal bus matrix works together. Notice how DMA1 and DMA2 are primarily connected to the D2 domain and SRAM isn't? Well, that did the trick for me. I've placed my DMA buffers in SRAM1 (which is directly connected to the D2 domain) and voila, everything started working.

Now to be fair, according to the documentation there should be a bridge between the D1 and D2 domain, but I'm not certain yet if ST's code generation covers setting it up right?

FMuel.1
Associate

Hello!

I found a solution for this problem. You have to set up the burst mode controller even if you just want to update one register and the dma should be triggerd by the repitation update event not by the compare event it self.

Here is the Main-File.

I hope I can help anybody with that information : D

Best regards,

Felix