cancel
Showing results for 
Search instead for 
Did you mean: 

DMA to TIM2 Frequency generation do not works

jihzed
Associate II

Hello.

We want use a Stepper X-NUCLEO-IHM14A1 with STSPIN820. We need to drive the STCK signal on the PB3 or PB10 GPIO. because we need some RAM and a CAN BUS, we choosed the STM32F446 (nucleo 64 board).

Each step will have different time, so we want to use DMA to timer. PB3 is used by SWO and there is only TIM2_CH3 on PB10.

I have found this tutorial : https://controllerstech.com/interface-ws2812-with-stm32/

and after changing the destination register CCR1 by ARR, it works fine... on the Timer 1 CH1.

But, we can't do the same on TIM2.

TIM1 CH1 is on the DMA2 / CH6 / Stream 1

TIM2 CH3 is on the DMA1 / CH3 / Stream 1

Is there any difference between TIM1 DMA2 and TIM2 DMA1 ?

4 REPLIES 4

> But, we can't do the same on TIM2.

What does this mean?

Read out and check/post TIM and DMA registers content. Compare between working and non-working case.

JW

jihzed
Associate II

In fact, I can link TIM1 and DMA2, TIM4 and DMA1, but we can't make a link TIM2 DMA1. We try another example : TIM4CH1 and TIM2CH1.

If we use PWM without DMA with HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1), it's run OK, so it's not a hard problem.

On this pict, the yellow is on TIM4CH1, with DMA1, and the blue signal TIM2CH2 with DMA1

0693W00000aJsMIQA0.jpg 

The configuration in Cube MX is the same, and the prorgam is the same.

0693W00000aJsMmQAK.jpg 

0693W00000aJsNBQA0.jpg 

0693W00000aJsNVQA0.jpgand for the 2 DMA the conf are the same :

0693W00000aJsNaQAK.jpg 

the test prorgam is very simple (pwmDataUp is a 32 * 16 bits data table)

0693W00000aJsMOQA0.jpg 

The DMA table in RM0390 page 207 :

0693W00000aJsOdQAK.jpg

>>Is there any difference between TIM1 DMA2 and TIM2 DMA1 ?

Different Buses, and DMA units.

TIM2 is 32-bit wide, don't do 16-bit DMA to it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jihzed
Associate II

Thank !

The TIM2 is 32 bits, the Tim1 & TIM4 are 16 bits. I always use the F103 where all the timer (1-4) are 16bits.

I jutse change the deep from 16 to 32… and it's run !

0693W00000aJskoQAC.jpgI was also put in error because on many (all ?) tutorial, they choose half word, and (for example) in the link I share in top, the reason is "I am using the data width of half word here, for no particular reason" …

thanks again !

(so now we need to generate tables of 32 bit words, I hope we have enough memory :face_with_tears_of_joy: )