cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_TxCpltCallback function is not being called

rtursen
Associate II
Posted on November 11, 2015 at 10:45

Hello,

I set up a uart project from CubeMx for STM32F0308 Disco, Basically I want to send ''test'' strings every 3 seconds via DMA however after I only get a single ''test'' in terminal. HAL_UART_TxCpltCallback function is never called.

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
{
/* Set transmission flag: transfer complete */
if(UartHandle->Instance == USART1){
HAL_GPIO_WritePin(GPIOC, LD4_Pin, GPIO_PIN_SET);
UartTXReady = SET;
}
}
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USART1_UART_Init(); 
while (1)
{
if(HAL_UART_Transmit_DMA(&huart1, (uint8_t *)''testing\n'', 5) != HAL_OK)
{
HAL_GPIO_WritePin(GPIOC, LD4_Pin, GPIO_PIN_SET);
Error_Handler();
}
while (UartTXReady != SET) { // do nothing }
HAL_Delay(3000);
}

CubeMx didn't provide any TXCpltCallback function so I had to add it myself. If I set the TX_DMA mode to Circular mode then I get a flood of ''testing'' strings as expected but I want t run it in Normal DMA mode and when it's like that, I only get a single ''testing'' in terminal any clues?
2 REPLIES 2
Posted on November 11, 2015 at 15:20

any clues?

IRQHandler's

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Day.Max
Associate
Posted on January 20, 2016 at 15:50

I found that HAL_UART_TxCpltCallback is not invoked using DMA transmit unless your DMA channel is configured in circular mode.  In normal mode, you just get the TC (Transmit Complete) bit set in the USART ISR.  You can poll this bit or, as Clive suggested, enable interrupts and write an interrupt handler.