2015-09-29 06:28 AM
Hello there,
I am trying to write a logger application using uart4 and DMA on STM32F4 discovery. I am usinh HAL lib and I can send through uart using regular transfer funtion without problem:HAL_UART_Transmit(&huart4, ''mama_'', 5, 1000);
But when I try to use the DMA version:
HAL_UART_Transmit_DMA(&huart4, ''mama_'', 5);
I can only send the message once, because after that this function returns status ''HAL_UART_STATE_BUSY''.
I am trying to send this message every 1 second. Why is DMA bussy in this time?
I have generated my config code using Cube software and when looking at the Hyperterminal examples its pretty similar. What am I doing wrong or what did i forget? I would apreciate all help.
2015-09-29 11:38 PM
Anyone please?
2015-09-30 12:50 AM
Are you handling the interrupts? Here is the code from the STM32F4 examples in STM32Cube_FW_F4_V1.8.0\Projects\STM32F4-Discovery\Examples\UART\UART_TwoBoards_ComDMA\Src\stm32f4xx_it.c:
/**
* @brief This function handles DMA RX interrupt request.
* @param None
* @retval None
*/
void
USARTx_DMA_RX_IRQHandler(
void
)
{
HAL_DMA_IRQHandler(UartHandle.hdmarx);
}
/**
* @brief This function handles DMA TX interrupt request.
* @param None
* @retval None
*/
void
USARTx_DMA_TX_IRQHandler(
void
)
{
HAL_DMA_IRQHandler(UartHandle.hdmatx);
}
/**
* @brief This function handles USARTx interrupt request.
* @param None
* @retval None
*/
void
USARTx_IRQHandler(
void
)
{
HAL_UART_IRQHandler(&UartHandle);
}
2015-09-30 02:06 AM
Hi Bremen,
You should add the function that handles USART interrupts./**
* @brief This function handles USARTx interrupt request.
* @param None
* @retval None
*/
void USARTx_IRQHandler(void)
{
HAL_UART_IRQHandler(&UartHandle);
}
Indeed, the function
''HAL_UART_IRQHandler()'' calls
''UART_Transmit_IT()'' function
that sets the USART state to
''HAL_UART_STATE_READY''. -Shahrzad-
2015-09-30 09:12 AM
Thats true, after handling interrupts the code started working. I didnt know it works like that. Thank you.