For our stm32f437xx device we use the latest(2.11.0) DFP package including CMSIS drivers. The USART driver works fine, but sometimes there is something curious. The driver doesn't stop to send data after the requested data are sent.
I debugged the issue, but I was not able to locate the problem.
/** \fn void USART_IRQHandler (const USART_RESOURCES *usart) \brief USART Interrupt handler. \param[in] usart Pointer to USART resources */ void USART_IRQHandler (const USART_RESOURCES *usart) { ... // Transmit data register empty if (sr & USART_SR_TXE & usart->reg->CR1) { // Break handling if (usart->xfer->break_flag) { // Send break usart->reg->CR1 |= USART_CR1_SBK; } else { if(usart->xfer->tx_num != usart->xfer->tx_cnt) { ... } usart->xfer->tx_cnt++; // Write to data register usart->reg->DR = data; // Check if all data is transmitted if (usart->xfer->tx_num == usart->xfer->tx_cnt) { ... } // USER CODE BEGIN else if(usart->xfer->tx_num < usart->xfer->tx_cnt) { log("Something went wrong"); } // USER CODE END } } ... }
It happends, that usart->xfer->tx_cnt is greater than usart->xfer->tx_num. And so of corse it will never stops. But I don't have an idea why that the step where usart->xfer->tx_cnt is equal to usart->xfer->tx_num is skipped.
But I suggest to change the if statment in that way:
// Check if all data is transmitted if (usart->xfer->tx_num <= usart->xfer->tx_cnt) { ... }
It stops to late, but at least it stops!!!