2022-07-15 04:02 PM
I am using STM32F411 and SDK v1.27.1
I am trying to trigger an DMA xfer with an external signal source using the TIMER1 External Trigger, without the need to execute any interrupts in the CPU to utilize the CPU time, as I have two signals one every 2ms and one every 150us that come from to different on board ICs, and when each signal is executed an SPI/UART xfer must be done to retrieve data in real-time.
I have used the code generator from the CubeIDE to generate Initialization code, an started the transfer in the main function
Here is the pinout view of the project
Timer1 Conig.
USART1 Config.
Code Snippets
#define BUFF_SIZE 8
uint32_t dma_TxBuffer[BUFF_SIZE] = {0};
uint32_t dma_RxBuffer[BUFF_SIZE] = {0};
HAL_TIM_Base_Start(&htim1);
/* Clear the TC flag in the SR register by writing 0 to it */
__HAL_UART_CLEAR_FLAG(&huart2, UART_FLAG_TC);
/* Enable the DMA transfer for transmit request by setting the DMAT bit
in the UART CR3 register */
ATOMIC_SET_BIT(huart2.Instance->CR3, USART_CR3_DMAT);
HAL_DMA_Start(&hdma_tim1_trig, (uint32_t)dma_TxBuffer, (uint32_t)&huart2.Instance->DR, BUFF_SIZE);
After debugging the code I found that the DMA register does not move the data at all
any help?
thanks
Solved! Go to Solution.
2022-07-16 02:28 AM
I don't use Cube/CubeMX, but it appears that you have set the slave-mode controller to clock the timer from the ETR pin. This will not generate Trigger events in the timer.
But ou don't need the Trigger events at all. Connect the external signal to some timer channel pin, set that channel to Input Capture, and set DMA to be triggered from the Capture event (TIMx_DIER.CCxDE).
JW
2022-07-16 02:28 AM
I don't use Cube/CubeMX, but it appears that you have set the slave-mode controller to clock the timer from the ETR pin. This will not generate Trigger events in the timer.
But ou don't need the Trigger events at all. Connect the external signal to some timer channel pin, set that channel to Input Capture, and set DMA to be triggered from the Capture event (TIMx_DIER.CCxDE).
JW
2022-07-16 02:53 AM
I looked up the Timer1 section in the reference manual and a dma trigger event can be generated from external trigger
2022-07-16 02:57 AM
Yes it can, but then you have to set up the Slave-mode controller to be in Trigger mode.
Read out and check TIMx_SMCR to see.
JW
2022-07-18 06:11 AM
Hello @Ahmed Nabih ,
Thanks for your feedback,
Please check the DMA inti order in Project Manager-> Advanced Settings, it has to be called before TIM1 init call (please refer to the attached screenshot )
If you are using CubeMX v6.5.0 or lower and in case the DMA init is called after the TIM inti, you need to apply the Workaround mentioned in this thread MX_DMA_Init order in the main.c file generated by STM32CubeMX, How to fix?
I hope this helps !
If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)
Sara.
2022-07-22 09:04 AM
I checked, but the init is done in it's right stages
thanks
A.Nabih
2022-07-22 10:06 AM
Thank you
You solved my problem