2023-03-27 01:45 PM
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 ?
2023-03-27 02:31 PM
> 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
2023-03-28 09:33 AM
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
The configuration in Cube MX is the same, and the prorgam is the same.
and for the 2 DMA the conf are the same :
the test prorgam is very simple (pwmDataUp is a 32 * 16 bits data table)
The DMA table in RM0390 page 207 :
2023-03-28 10:59 AM
>>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.
2023-03-28 12:03 PM
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 !
I 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: )