AnsweredAssumed Answered

In UART RS485 transmission the last byte always missing in HTERM (STM8S003F3)

Question asked by Lei Sun on Nov 27, 2017
Latest reply on Nov 28, 2017 by Clive One

Hi all, I am using currently STM8S003F3 for my work and I want to send an array of bytes to the HTERM on my PC using UART RS485. But I always miss the last byte in the array (I can't see the last byte in HTERM). Here is a shot code snippet:


_UART_TX_ON; //switch to UART485 transmission mode
for ( bn=0; bn<17; bn++) {
   UART1->DR = bSPIRxBuf[bn]; //UART1_SendData8(bSPIRxBuf[bn]);
   while ( (UART1->SR & 0x80) == 0x00); //while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
_UART_RX_ON; //switch to UART485 reception mode

The array bSPIRxBuf[0-16] has already some predefined content. But in Hterm I can only observe 16 bytes, which means the last byte is always not received by HTERM. I don't know why and could not explain. I think that I have waited enough time for each transmit byte before switching to reception mode using the while function. Anyone has some ideas? Many thanks!