This page was machine-translated and may differ from the original. View original

[Serial] ST Yuji Kawano Engineer (20) - Is UART communication possible without an external oscillator?

Google 우선 소스Published2022.11.02 14:56
UART communication, can be implemented with built-in oscillator circuit

UART communication operation with clock frequency error within 2% to 3%
STM32F103, user frequency adjustment register provided

[Editor's Note] When we talk about semiconductors, we tend to think of semiconductors that are familiar to the general public, such as the CPU and memory of computers. On the other hand, MCUs (Micro Controller Units), which are core semiconductors used to operate electronic products, are semiconductors that are still unfamiliar to the general public, even though they are commonly used in all electronic products that we easily come across. These MCUs have recently been in the news due to the semiconductor shortage, and they are beginning to attract the attention of the general public. Accordingly, our magazine has prepared a place to learn about MCUs through a series of articles by Yuji Kawano, Manager of ST Microelectronics, a company specializing in MCU semiconductors.



■ Question

We are planning to use UART (Universal Asynchronous Receiver Transmitter) communication, and are considering using the MCU's built-in oscillator circuit as a clock source for the UART to minimize the number of components. I am wondering if UART communication can be implemented using the built-in oscillator circuit, or if an external oscillator element must be used.

■ Answer

There is no clock terminal for UART communication, but the UART is synchronized with the internal clock of the MCU (see Figure 1). Generally, if the clock frequency error is within 2% or 3%, the UART communication will work. If the frequency of the MCU's built-in oscillator circuit is within this range, it can be used. If the MCU has a PLL and the UART uses the PLL output clock, the PLL frequency error must be taken into account. The clock frequency error of the corresponding component to be communicated must also be taken into account. If the component has a frequency error of more than 2%, the MCU frequency error must be less than 1% so that the total error does not exceed 3% to prevent communication errors. Please refer to the data sheet for information on the frequency error of the MCU's built-in oscillator circuit and PLL.

▲Figure 1: UART (Universal Asynchronous Receiver Transmitter)

■ Path from clock source to UART

There are multiple clock dividers (also called prescalers) on the path between the MCU's built-in oscillator circuit and the UART module to adjust the UART communication speed. Some MCUs have a phase locked loop (PLL) located immediately after the built-in oscillator circuit or closer to the UART module to increase the frequency. Figure 2 shows these two configurations (depending on whether or not there is a PLL). Figure 2(a) shows the configuration of STMicroelectronics' STM32F103 with PLL, and Figure 2(b) shows STMicroelectronics' STM8S without PLL. In Figure 2(a), the clock generated by the built-in oscillator circuit is half of its original size before being fed to the PLL. The PLL multiplies the clock from 2 to 16 and feeds it to another divider. This divider divides the clock again to provide a clock at the user-designed frequency before providing the frequency to the UART module.

The configuration in Figure 2(b) does not have a PLL. The clock frequency is divided by two dividers to become the user-designed frequency before being supplied to the UART module.

Next, let's look at the frequency errors generated by each circuit in this path.

▲Figure 2: Example of a path from a clock source to a UART

■ MCU built-in oscillator circuit

Typically, the oscillator circuits built into MCUs are ring oscillators that use resistors (R) and capacitors (C). The frequency is determined by the values of R and C; since these values vary depending on the MCU manufacturing conditions, the oscillation frequency also varies depending on the product.

The frequency of some modern MCUs is calibrated (tuned or trimmed) before shipping to maintain a certain range of frequency errors. In most cases, this is adjusted to a range of about 1%. Figure 3 shows the frequency error of the STM32F103 at the time of shipment.

The error of the internal oscillator circuit, which was calibrated before shipment, is shown in the red box in Figure 3. The table shows that the frequency error for this type of MCU is calibrated to between -1.1% and +1.8% for TA (MCU temperature) of 25℃. For TA from -40℃ to 105℃, the error varies between -2% and 2.5%. This is within the allowable range of UART communication.

STM32F103 provides a register to adjust the frequency of the built-in oscillator circuit so that users can adjust it after purchase, and the specifications for this are shown in the blue box in Figure 3. By setting the RCC_CR register, users can reduce the error to less than 1%, so that UART communication can be supported. It should be noted that a reference frequency is required for calibration. Calibration is absolutely necessary to generate the correct frequency with the minimum possible error characteristic. Adjustment must be made based on this frequency. A clock crystal oscillator can be used as a reference frequency generator during calibration.

▲Figure 3: Error in built-in oscillation circuit of actual product

■ Distributor

Since a divider is generally a digital (logic) circuit that divides the clock, the frequency error after the divider does not change and remains at the same ratio. The divider consists of a basic down-counter, which outputs a pulse that counts two each time, or n clock pulses each to form a 1/2 divider, a 1/3 divider, or a 1/n divider.

Since counting clock pulses does not affect the frequency error, the original frequency error is transmitted as is. However, since the division method varies depending on the MCU, you should check with the MCU manufacturer.

■ PLL (phase locked loop)

A PLL can amplify a clock by 2, 3, or n. The frequency error of the amplified clock is essentially unchanged, but the amplified clock waveform contains jitter. Jitter is a phenomenon in which the rising/falling edge positions of the clock pulse signal temporarily shift.

Figure 4 shows the PLL specifications and jitter characteristics of STM32F103. The jitter value is shown in the red box. Since the unit is ps, the value is very small. Of course, the jitter partially changes the clock period, but it does not affect the entire clock period, which means that the frequency is not affected.

However, these details are only for the STM32F103. Different MCUs have different PLL types and characteristics. You should check the datasheet of each MCU for the characteristics of the PLL, and if the PLL generates frequency errors, you should definitely consider whether this could be the cause of UART communication errors.

▲Figure 4: PLL characteristics

■ Wrap-up

In summary, the most influential factor is the frequency error of the MCU's built-in oscillator circuit. Dividers and PLLs generally do not cause frequency errors. (Note: You should check the details of each MCU.)

Therefore, whether UART communication is possible or not must be determined by considering the frequency error of the MCU's built-in oscillator circuit and communication-related components.

■ Other communication methods

Briefly explain other communication methods. Generally, clock-synchronous communication methods output a data-synchronized clock. When using such a clock to synchronize input data, there is no need to worry about frequency errors. For example, SPI (serial peripheral interface) and I2C (inter-integrated circuit) are clock-synchronous methods and are not affected by MCU internal clock frequency errors.

Besides UART, USB (universal serial bus) is an asynchronous communication method. Each USB specification (e.g. full-speed or high-speed) specifies a frequency error. Some specify that the frequency error should be within ?0.25%, in which case the MCU's built-in oscillator circuit cannot be used, so an external oscillator must be used.

However, some MCUs today can communicate via USB without an external crystal oscillator (e.g., STM32L0x2 from STMicroelectronics). Please check the specifications of each MCU.
본 기사에 대한 정정·반론·추후보도 청구는 보도 청구 안내를, 그간 게재된 보도문은 정정·반론보도 모아보기를 참고해 주세요.
명세환 기자
명세환 기자