AnsweredAssumed Answered

HAL_UART_TxCpltCallback function is not being called

Question asked by rifo.rifo on Nov 11, 2015
Latest reply on Jan 20, 2016 by Day.Max
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?

Outcomes