You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the same way it was nice to input directly strings terminated with \n:
static volatile uint8_t uart_rxHead, uart_rxTail, RXDComplete;
#if defined (UART_MODE_RX)
if (status & UART_IT_RXC_ENABLE) // byte received, the same bit as in CTRL1
{
data = USART1->DATAR;
tmp8 = (uart_rxHead + 1) & UART_RX_BF_MASK;
if (tmp8 == uart_rxTail) lastErr |= UART_ERR_RXBUF_OVERFLOW;
uart_rxHead = tmp8;
if(data != '\n' && data != '\r') {
uart_rx_bf[tmp8] = data;
} else {
uart_rx_bf[tmp8] = 0;
RXDComplete = 1;
}
}
lastRXerrorFlag = lastErr & 0xFF00;
#endif
Just ask for the flag with if (RXDComplete) and reset it to 0 after fetching and computing the string.
I have a strange sporadic error transmitting data through the UART to an chinese PL2303 USB-converter.
Sometimes the second byte of a transmitted string was wrong. So I thought that 115200 baud is to much, but the same error occurs at 57600 baud. There is no idea what is causing it.
But there was the need to set another baud rate and so the register values have to be calculated.
This is done with this Calc-file, so other crystal frequencies can be used and there are some more sheets with calculators, that will comfortable decode some other registers.
(ods cannot be uploaded here, so please save the file and delete the ending .jpg)
The baud rate can be set directly after the init of the UART:
UART_init();
USART1->BRR = 0x341; // 57600 Baud
That's it - much fun.
The text was updated successfully, but these errors were encountered:
Thank you for this nice libraries - they are very helpful!
The ch32v003_uart.h is missing a function to set the baud rate and a simple function to transmit strings without the use of printf.
Here is the simple function to be added to output strings:
Now you can simple output with
uart_string("Test");
or with
In the same way it was nice to input directly strings terminated with \n:
Just ask for the flag with if (RXDComplete) and reset it to 0 after fetching and computing the string.
I have a strange sporadic error transmitting data through the UART to an chinese PL2303 USB-converter.
Sometimes the second byte of a transmitted string was wrong. So I thought that 115200 baud is to much, but the same error occurs at 57600 baud. There is no idea what is causing it.
But there was the need to set another baud rate and so the register values have to be calculated.
This is done with this Calc-file, so other crystal frequencies can be used and there are some more sheets with calculators, that will comfortable decode some other registers.
(ods cannot be uploaded here, so please save the file and delete the ending .jpg)
The baud rate can be set directly after the init of the UART:
That's it - much fun.
The text was updated successfully, but these errors were encountered: