Skip to main content
fozen.1
Associate
October 7, 2021
Solved

STM32G0 Nucleo DMA Question

I use nucleo-g071rb board. I want to read Infrared datas via IR Led and send it to another IR receivers with different IR Led. For purpose I used timer2's channel 1 with input capture direct mode. I used dma here to see datas. I have a problem with dma.

I made polarity to both edges and I don't know exact data number, because different IR transmitters have different data sizes. That's why I used HAL_TIM_IC_Start_DMA function with 512 half word size. Here I want to record all datas from zero but I see it continues to record where is stays. I mean if 71 bytes datas came, it continues to write from 72. How I set it to start from 0 every time ?

This topic has been closed for replies.
TDK
TDKBest answer
October 7, 2021

You'll need to stop the transfer with HAL_TIM_IC_Stop_DMA and restart it again if you want it to start from 0.

Another option would be to use a circular buffer and pop values out of it as needed.

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

TDK
TDKBest answer
October 7, 2021

You'll need to stop the transfer with HAL_TIM_IC_Stop_DMA and restart it again if you want it to start from 0.

Another option would be to use a circular buffer and pop values out of it as needed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
fozen.1
fozen.1Author
Associate
October 7, 2021

Thank you @TDK​ ,

How can I stop the transfer by using HAL_TIM_IC_Stop_DMA function ?

I use HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) function but it waits to full the size, in that callback I use HAL_TIM_IC_Stop_DMA as you said, but it is too late for me. I should not wait till 512 bytes received. Could you show me how(where) to use it ?

I have no experience circular buffer usage, also it could be good to see how it is happening.

TDK
October 7, 2021

You need to detect the end of whatever event you're trying to capture, and call it then. I don't know the details of your application. How do you know when it's the "end"?

"If you feel a post has answered your question, please click ""Accept as Solution""."