Это у меня в прерывании CH32V203, не модбас. if(UART4->STATR & USART_STATR_TC){
ii = TxFifo_4.ct; /* Number of data in the FIFO */
if(ii){ /* If any data is available, pop a byte and send it. */
GPIOB->BSHR = GPIO_BSHR_BS14; // RE_/TE RS485
TxFifo_4.ct = --ii;
ii = TxFifo_4.ri;
UART4->DATAR = TxFifo_4.buff[ii++]; /* Send a byte */
TxFifo_4.ri = ii % BUFFER_SIZE; /* Next read ptr */
}
else { /* No data in the Tx FIFO */
UART4->CTLR1 &= ~USART_CTLR1_TCIE; /* Stop transmission sequense */
GPIOB->BSHR = GPIO_BSHR_BR14; // RE_/TE RS485
}
}