Using IMO for UART Communication in PSoC® 3 and PSoC 5LP - KBA203603 | Cypress Semiconductor
Support & Community
Using IMO for UART Communication in PSoC® 3 and PSoC 5LP - KBA203603
Can we use a clock derived from the internal main oscillator (IMO) for UART Communication in PSoC 3 and PSoC 5LP?
Yes, a clock derived from the IMO can be used for UART if the IMO accuracy is within +/- 2%.
UART is an asynchronous communication protocol. The protocol relies on an agreement of clock speeds on transmitter and receiver sides. If clocks on the transmitter and receiver sides of a UART link are highly mismatched, it will result in an erroneous communication.
PSoC 3 and PSoC 5LP UART use an 8x clocking for receiver state machine. It means that the receiver logic samples the input at eight times the baud rate. The UART data frame consists of 1 start bit, 5 to 9 data bits, and 1 or 2 stop bits. The receiver is synchronized at the falling edge of the start bit; the worst-case timing error will be at the stop bit.
The worst-case timing error to receive the stop bit correctly is a half-bit period because the receiver samples the incoming bits in the middle of the bit period. The stop bit is 76 (9.5 × 8) UART clocks from the start bit. The half-bit period translates to four UART clock periods in the 8x clocking scheme. There will be a maximum of one clock-cycle error due to synchronization, which leaves us with three clock-cycle errors that the UART can tolerate over 76 UART clock cycles. This translates to an approximately 4% (3/76) mismatch between transmit and receive clocks. Therefore, the worst-case clock mismatch between UART transmit and UART receive nodes must be +/- 4% for the UART to work correctly.
Allowing the transmitter and receiver to share the mismatch equally with respect to the baud rate of the UART, PSoC is allowed to have a +/- 2% error in UART clock so as to communicate successfully over UART. Thus, to use a clock derived from the IMO for UART communication, the IMO accuracy must be within +/- 2%.
This accuracy requirement is fulfilled by the IMO in following three conditions
- When IMO = 3 MHz, Accuracy = +/- 1%
- When IMO = 6 MHz, Accuracy = +/- 2%
- When IMO = 24 MHz and the USB clock is derived from the IMO, Accuracy = +/- 0.25%
All other settings of the IMO result in clocks that are more than +/- 2% inaccurate.
Therefore, a clock derived from the IMO can be used for UART only when the IMO is operating in one of these three cases. If the IMO does not operate at one of these conditions, an accurate external clock source or a crystal oscillator should be used to derive the clock for the UART.