- Silicon Labs Community
- Welcome and Announcements
- Silicon Labs Knowledge Base
- 8-bit MCU
- 32-bit MCU
- Bluetooth / Wi-Fi
- Other Products Category
- Optical/RH/Temp Sensor
- Other Products
- Hardware and Software Tools
- Simplicity Studio and Software
- General Discussions and Suggestions
- Chinese Forum
- Software Libraries
- Development Kits
- Reference Designs
- Third Party Tools
- White Papers
- Official Blog of Silicon Labs
- Chinese Blog
06-23-2017 12:33 AM - last edited on 07-21-2017 08:42 AM by Siliconlabs
Hey guys i am new to simplicity studio and was n trying to print out some sensor values .
So i have a print statement that i have redirected using retarget serial.c.
But when i connect to a serial port and go i get the following output on my terminal
after this it randomly stops and spurts out random characters . I paused the program using the debugger and noticed it stopped at while (!(usart->STATUS & USART_STATUS_TXBL)) in uart_tx
Any suggestions on how may i proceed with this?
i need it to continuosly print out sensor readings
06-23-2017 03:29 AM
Since the program will spend most of its time waiting in that loop, it is not surprising that you break there.
Do you maybe have a watchdog biting or some other reset cause? It could make the serial data train hicup and get out of sync. I suspect the data comes continously without inter-character delays.
06-24-2017 02:12 PM
06-29-2017 05:19 PM
After a frame error a uart needs some quiet time on the line to resynchronize. A continuous transmission can keep it out of sync.
I forget what exactly that "quiet time" after a byte is sent, but I think it's on the order of a bit time after the stop bit is transmitted. If you consider that at 115200 bps the bit time is 8.68 us, that's forever when the processor clock speed is a measly 25 MHz (40 ns). The DMA engine controlling the transmission can see that the transmit shift is complete, perhaps meaning "stop bit just started transmitting," because the stop bit idles the TX line. And then in a very few clock ticks it can turn around and start sending the next byte, indicated by bringing the TX line low for the start bit. The receiver may not be ready for that event.
06-30-2017 06:02 AM
I'm sure the UART will wait the full stop bit before transmitting the next start bit. But when you go out of sync that is not enough. In that case you need a full byte of silence to recover, because the next start bit may be interpreted as part of the previous byte and the receiver may think any of the following '0' bits is the start bit.Using two stop bits on transmit helps to stay in sync.