2021-10-06 11:56 PM
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 ?
Solved! Go to Solution.
2021-10-07 06:09 AM
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.
2021-10-07 06:09 AM
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.
2021-10-07 07:01 AM
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.
2021-10-07 08:08 AM
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"?