two UART DMA with timer interrupt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 12:39 AM
Hi, all
I am trying to receive packet from uart3 and send them to uart2
but the results of my trials are:
- transmit occurs every main cpu clock
- transmit occur just once
which I thought was:
- receive packet from uart3 when packet arrived, independently
- transmit that packet once for every 65ms
My problem is "once" and "every 65ms"
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
HAL_DMA_Abort_IT(&huart2);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
HAL_UART_Receive_DMA(&huart3, (uint8_t*)b, 2);
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
HAL_UART_Transmit_DMA(&huart2, (uint8_t*)b, 2);
}
HAL_UART_Receive_DMA(&huart3, (uint8_t*)b, 2);
It's what I tried, "b" is uint8_t array
Thanks.
Solved! Go to Solution.
- Labels:
-
DMA
-
Interrupt
-
STM32F4 Series
-
TIM
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 1:02 AM
Hello @Frogram​ and welcome to the Community :)
Please take a look into the STM32 UART DMA RX/TX application note contains explanation with examples.
Hope this helps you!
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 1:02 AM
Hello @Frogram​ and welcome to the Community :)
Please take a look into the STM32 UART DMA RX/TX application note contains explanation with examples.
Hope this helps you!
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 1:06 AM
Thanks!
I will check them right now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 5:40 AM
I have no idea how to apply this in my project... TT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 11:19 AM
You don't need to call HAL_DMA_Abort_IT at the end of a completed transfer.
The other calls should work. Consider simplifying the problem by removing the timers and implementing a fixed delay. Toggle a pin instead of using UART to verify timings. Monitor return value from HAL calls to ensure they succeed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-24 11:32 PM
/*inside of main*/
HAL_TIM_Base_Start_IT(&htim6);
HAL_UART_Receive_DMA(&huart2, (uint8_t *)b, 8);
/*outside of main*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if (htim == &htim6) {
HAL_UART_Transmit_DMA(&huart3, (uint8_t *)b, 8);
}
}
It worked! thanks all
