cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 Nucleo DMA Question

fozen.1
Associate

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

3 REPLIES 3
TDK
Guru

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".

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.

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".