cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 two PWM pulses with different lengths by using DMA

AAnge.3
Associate

Good evening ST experts, I hope that some of you can help me with my problem.

As the titel already states, I am trying to generate two pulses with different lengths (same length, but different CCRs) by using a DMA timer function:

HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)pwmData, 2);

I saw a tutorial on youtube on it and it seemed to work for him but in my case it only generates one pulse with the CCR of the first place in my array pwmData

uint8_t pwmData[2];

pwmData[0] = 80;

pwmData[1] = 20;

 

Is this a common problem and if so, what's the solution for the problem? I couldnt find any answers on the internet so I'd be really greatful for a solution. 

If you have an idea for what the error might be but need more code just tell me and I'll share the requested files with you.

Here are some notes I made on how I planed to do the task:

SCR-20230703-twzs.png

2 REPLIES 2

Read out and check/post content of TIM and relevant DMA registers and the buffer in memory.

Ideally, in debugger, step into the Cube/HAL function up to the point where the DMA is going to be started, either by enabling DMA or the related DMA flag in TIMx_DIER (I don't use Cube so don't know which one is it) and observe the registers' content there.

JW

Sarra.S
ST Employee

Hello @AAnge.3, thank you for your post, 

Try changing pwmData[] size to 16 bits since CCR registers are 16 bits wide 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.