September 2015 DocID17825 Rev 2 1/16
1
AN3258
Application note
STM8AF and STM8S series HSI oscillator calibration
using LIN automatic resynchronization
Introduction
Local interconnect network (LIN) is a widely used standard for communication between
various nodes present inside the electronic control unit (ECU) of a vehicle. LIN sync frame,
which is defined by LIN standard, is used as a reference by the LIN slave nodes for clock
synchronization. Using this technique, LIN slave nodes can calibrate the variable internal
RC oscillator and use it as the system clock source. Therefore, the LIN slave node
application can save the cost of using crystal or resonator oscillators.
This application note describes a method to calibrate the STM8AF and STM8S series high-
speed internal (HSI) oscillator using the LIN automatic resynchronization feature of the
LINUART peripheral. The calibration method is also provided with a software routine. It can
be downloaded from
www.st.com.
The user must be familiar with the LIN bus standard, STM8AF and STM8S series
architecture, and the basics of C language. Detailed information about the STM8AF and
STM8S series microcontroller peripheral features, hardware registers, and electrical
characteristics are available in STM8S series and STM8AF series 8-bit microcontrollers
reference manual (RM0016) and the product datasheets.
www.st.com
Contents AN3258
2/16 DocID17825 Rev 2
Contents
1 HSI calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 HSI trimming bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 LIN automatic resynchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 HSI calibration method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 HSI calibration routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.5 LIN header error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.6 LIN divider update method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.7 LIN clock deviation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15