2021-07-04 12:37 PM
Hi! I know overall idea of DMA and i need to use it but i have no idea how to do it.
I found one post with same question but i didn't found any helpful info for me. I'm not advanced in case of using registers. I used them to directly change CCR and ARR sometimes, so I need a direct answer.
Edit: It is worth mentioning that I use CubeIDE
Thanks for help
2021-07-04 01:44 PM
Make TIMx_ARR to be the target of the DMA transfer on the peripheral side. Make sure ARR preload is switched on.
JW
2021-07-04 01:57 PM
Could you explain it further, especially first part? How i can make TIMx_ARR target of the DMA transfer?
2021-07-04 03:09 PM
You write it in the Peripheral address register of DMA channel/stream, while the channel/stream is set to transfer memory-to-peripheral.
Read the DMA chapter first. You may also want to read the Timer cookbook AN4776. And next time start with stating which STM32 are you using.
JW
2021-07-04 11:11 PM
I'm using stm32f407g
2021-07-04 11:20 PM
I use here a DMA(triggered with a timer)---->PWM(timer) to create a neopixel LED driver, maybe you can fish something out, specially the DMA+PWMtest.
The mcu shouldnt matter as long as you have DMA and TIM available to use.
I tested this with stm32f103 and stm32f7
2021-07-05 04:04 AM
You use HAL_TIM_PWM_Start_DMA function but if i understand it correctly, it can access only TIMx_CCRx registry but i need TIMx_ARR
2021-07-05 04:26 AM
what if you try this inside HAL_TIM_PWM_Start_DMA()
//instead of this:
if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
{
//do this :
if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->ARR, Length) != HAL_OK)
{
2021-07-05 06:19 AM
It does not work, just returns HAL_ERROR. Standard version is working correctly.
Also your example is not correct, when you are calling the function you should put uint32_t pointer as pData, not uint8_t. When i changed that it was working back again.
2021-07-05 06:55 AM
sorry to hear that...
fyi: is not my example, i just copy pasted, this code comes from the HAL_TIM_PWM_Start_DMA API provided with the HAL libraries maintained by STM
maybe your DMA configuration is set up as Byte instead of word.
ill look into that next time i get into that project, thanks