2020-04-14 11:00 AM
Hi, I am trying to capture all GPIO pin values when timer pin goes LOW. I cant understand which timer I need to choose? Which peripheral stands for GPIO port?
How do I need to set Timer "Copy from" input source?
I have STM32F091RC
Solved! Go to Solution.
2020-04-14 12:51 PM
>>I cant understand which timer I need to choose?
It is not complicated, but does require logical deduction and reading of the technical documentation.
There's a chain of associativity in the Reference Manual. Pick a TIM on APB2 (DMA2) for parts where that is required for Mem-to-Mem DMA
Find a TIMx_CHx pin you can use for Input Capture, and that same TIMx_CHx appears in the DMA channel/stream Trigger sources.
Use DMA in Mem-to-Mem, with GPIOx->IDR as the SOURCE, read as a word or halfword, and have the memory array / pattern buffer as the DESTINATION
2020-04-14 11:51 AM
I cant understand which timer I need to choose?
Whichever, which has its capture/compare unit brought out to pins (i.e. not TIM6/TIM7), and which can trigger DMA operations (read DMA chapter in RM for your STM32 model).
You did not tell us your STM32 model, but in 'F2/'F4/'F7 you need to use timer which can trigger DMA2 streams (and 'H7 has some additional bonus levels of complexity).
> How do I need to set Timer "Copy from" input source?
There's no such, unless you talk about some Cube/CubeMX gibberish.
Read AN4666.
JW
2020-04-14 12:51 PM
>>I cant understand which timer I need to choose?
It is not complicated, but does require logical deduction and reading of the technical documentation.
There's a chain of associativity in the Reference Manual. Pick a TIM on APB2 (DMA2) for parts where that is required for Mem-to-Mem DMA
Find a TIMx_CHx pin you can use for Input Capture, and that same TIMx_CHx appears in the DMA channel/stream Trigger sources.
Use DMA in Mem-to-Mem, with GPIOx->IDR as the SOURCE, read as a word or halfword, and have the memory array / pattern buffer as the DESTINATION
2020-04-14 01:10 PM
Ok, so as I understood Timer itself does not have some kind of "copy and pass GPIO state to DMA input" logic correct?
I need to wait for half or full complete interupt of the timer and implement copy of GPIOx->IDR Mem-to-Mem myself correct?
2020-04-14 01:10 PM
Ok, so as I understood Timer itself does not have some kind of "copy and pass GPIO state to DMA input" logic correct?
I need to wait for half or full complete interupt of the timer and implement copy of GPIOx->IDR Mem-to-Mem myself correct?
2020-04-14 02:18 PM
Moving data is not the Timer's task, it's DMA's task. Timer in this context just provides a means to trigger the DMA.
Read AN4666.
JW
2020-04-15 08:43 AM
I cant set CCR1 but basicaly what I need it this:
htim2.Instance->CCR1 = (uint32_t)&GPIOC->IDR;
How do I achieve that?
2020-04-15 08:47 AM
Yes I am trying to use CubeMX, I cant choose MemToMem DMA operation with timer there
I can choose only Peripheral to Memory or Memory to Pheripheral, so not sure how to copy GPIO values.
Basicaly what I do is this:
HAL_TIM_IC_Start_DMA(
&htim2,
TIM_CHANNEL_1,
(uint32_t *)&BUFFER_DATA[0],
BufferSize);
but the problem here is that I cant add source from where to copy. It copies data from
htim2.Instance->CCR1
And It seems that I cant simply set it
htim2.Instance->CCR1 = (uint32_t)&GPIOC->IDR;