AN2575 Freescale Semiconductor / Motorola, AN2575 Datasheet

no-image

AN2575

Manufacturer Part Number
AN2575
Description
MC68HC908EY16 ESCI LIN Drivers
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2575/D
9/2003
MC68HC908EY16 ESCI
LIN Drivers
By: Wolfgang Bihlmayr
and Peter Topping
Introduction
CodeWarrior is a registered trademark of Metrowerks, Inc., a wholly owned subsidiary of Motorola, Inc.
This product incorporates SuperFlash
Motorola, Munich
Motorola, East Kilbride
Reliable communication via the asynchronous LIN
with a bus clock accurate enough to avoid errors. MCUs that use clocks based
on crystal or ceramic resonators easily provide very accurate bus clocks. The
LIN protocol was designed to also allow more cost-effective solutions. MCUs
with on-chip oscillators can be successfully used, even though the on-chip
oscillators have accuracy poorer than a crystal’s by several orders of
magnitude.
The most significant change from normal UART timing is the increase of the
usual 10-bit break to 13 bits. This allows an MCU with an inaccurate clock (up
to ±14%) to reliably distinguish a break from a data byte containing eight zeros
(nine including the start bit). Following this break, the protocol specifies the
inclusion of a synchronization byte whose data is always $55. This field
includes five falling (recessive to dominant) edges that can be used as a
reference for clock and/or baud rate adjustments.
The MC68HC908EY16 is a high-performance MCU suitable for use in a low-
cost LIN slave node. It can be used with or without an external crystal. To
enable use without a crystal or any other external clock component, it
incorporates an internal clock generator (ICG). The ICG can be programmed
to any frequency from 307.2 kHz to 32 MHz in increments of 307.2 kHz. As with
all HC08 MCUs, the bus frequency is one-quarter of this clock frequency. The
use of the ICG reduces cost and eliminates the need for pins dedicated to clock
circuitry. Not putting the clock on external pins also greatly reduces electro-
magnetic emissions — see application note AN2344/D: HC908EY16 EMI
Radiated Emissions Results. (This document and other helpful documents are
listed in the
1. Local Interconnect Network, see the
Freescale Semiconductor, Inc.
For More Information On This Product,
technology licensed from SST.
References
Go to: www.freescale.com
section.)
References
section.
1
protocol requires an MCU
© Motorola, Inc., 2003

Related parts for AN2575

AN2575 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2575/D 9/2003 MC68HC908EY16 ESCI LIN Drivers By: Wolfgang Bihlmayr Motorola, Munich and Peter Topping Motorola, East Kilbride Introduction Reliable communication via the asynchronous LIN with a bus clock accurate enough to avoid errors. MCUs that use clocks based on crystal or ceramic resonators easily provide very accurate bus clocks. The LIN protocol was designed to also allow more cost-effective solutions ...

Page 2

... Freescale Semiconductor, Inc. AN2575/D NOTE: With the exception of mask set errata documents, if any other Motorola document contains information that conflicts with the information in the data sheet, the data sheet should be considered to have the most current and correct data. The downside of using the ICG is that the frequency is not as accurate as that of a crystal or resonator. Parametric spreads during manufacture result in an overall untrimmed accuracy of ± ...

Page 3

... For More Information On This Product, Table Table 1. LIN Baud Rate Requirements Accuracy ±14% (1) ±2% ±1% MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Baud Rate Requirements for LIN 1. Slave-to-slave communication using Condition Master clock accuracy assumed to be within ±0.5% of nominal Relative to the master’s clock 3 ...

Page 4

... Freescale Semiconductor, Inc. AN2575/D One method of initially trimming the ICG is fully described in AN2498/D (see the References up with a value that is stored in FLASH and loaded into the ICGTR register. This value can be either embedded into the code (as shown in the software listing) or stored in a pre-defined FLASH location and transferred to ICGTR on power-up. With this pre-trimming done on an MC68HC908EY16, the frequency is guaranteed to be within ± ...

Page 5

... OR 2 8.96875 4 (BYPASSED ÷ 2 ÷ 4 Figure 1. ESCI Baud-Rate Prescalers MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D ESCI Prescaler Baud Rate Adjustment BAUD RATE DIVIDER — BD ÷ ÷ ..128 ESCI Rx ACLK = 1 9-BIT ARBITER COUNTER ...

Page 6

... Freescale Semiconductor, Inc. AN2575/D Figure 1 The input clock to the arbiter counter is selected according to the mode being used. In the bit-time measuring mode being used here, the ACLK bit in the arbiter control register (SCIACTL and the arbiter counter is clocked at one- quarter of the ESCI input clock. This input clock is selectable in CONFIG2 to be either the bus clock or the CGMXCLK clock, which is bus × ...

Page 7

... SCPSC register. MOTOROLA For More Information On This Product PDFA = 1 + PDS + PSSB ÷ SCPSC ÷ 32 SCPSC = 32 × ((count ÷ 64) – count ÷ 2 – $20 MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D ESCI Prescaler Baud Rate Adjustment arbiter count finished ? // 19200 baud // count - 32 // 9600 baud // count/2 – ...

Page 8

... Freescale Semiconductor, Inc. AN2575/D Hardware The LINkits LIN evaluation board described in AN2573/D application × 16 character LCD has been added using the same interface as that described in AN2498/D. The complete circuit diagram used here is shown in regulator (in this case an LT1121) is required to implement the simple LIN node ...

Page 9

... MOTOROLA For More Information On This Product, REGISTER INDICATOR ICGTR f HEX VALUE Bus 128(t80) 4915 42 100.0 9600 31 TEMPERATURE % f BAUD RATE nom References section). The two-digit temperature is MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Hardware PD 3 PSSB 9 ...

Page 10

... Freescale Semiconductor, Inc. AN2575/D In addition to the reset button, two buttons (trim and adjust) are also included, as shown in AN2498/D (see References). Pressing the trim button causes a trim calculation and adjustment to take place. This function is debounced so that only a single trim takes place even if the button is held down. The adjust button can be used to manually change the value of ICGTR ...

Page 11

... The difference between the current value and the previous value is calculated. Then that delta is put into the array of 16 values that are used for the average frequency display. MOTOROLA For More Information On This Product, MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software 11 ...

Page 12

... Freescale Semiconductor, Inc. AN2575/D 12 For More Information On This Product, START INITIALIZE CONFIG, PORTS, TBM, TIMER A, AND ICG MULTIPLIER INITIALIZE LIN DRIVERS AND THE LCD MODULE. ENABLE INTERRUPTS. NO TBIF FLAG SET ? YES CLEAR TIMEBASE INTERRUPT FLAG TOGGLE “TICK” LED YES ADJUST BUTTON ...

Page 13

... MHz. This is acceptable, but is near the limit. Therefore, the use of lower baud rates necessarily implies the use of lower bus speeds. MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Alternative Strategies and ...

Page 14

... Freescale Semiconductor, Inc. AN2575/D Software Listing /****************************************************************************** * (c) MOTOROLA Inc. 2003 * * * MC68HC908EY16 ESCI baud rate trimming demonstration program. * ============================================================ * * Originator: P. Topping * Date: 22nd June 2003 * Revision: 1.0 * Function: LCD display of the ESCI prescaller settings which are * automatically adjusted by the LIN drivers (1.3), The * code includes the ability to adjust or trim the ICG to * force changes to the fractional divide prescaler value ...

Page 15

... PD; unsigned char tmpSCPSC; MOTOROLA For More Information On This Product, -"; MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing 15 ...

Page 16

... Freescale Semiconductor, Inc. AN2575/D /****************************************************************************** * * Function name: Main * Originator: P. Topping * Date: 21th March 2003 * Function: Initialise CONFIG registers, ICGMR, Ports and Timers. * Initialise LCD module & LIN drivers and enable interrupts. * Pace a slow loop (~4Hz for a 4MHz bus) using the timebase * module. Within this loop the keys are read, the LIN buffer * is read and the LCD module is updated ...

Page 17

... A2 & check for LIN message /* constant for this ICGMR */ /* data for LCD line 1 /* data for LCD line 2 /* DDRAM address to line and write LCD line 1 /* DDRAM address to line and write LCD line 2 MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing */ */ */ */ */ 17 ...

Page 18

... Freescale Semiconductor, Inc. AN2575/D /****************************************************************************** * * Function name: Read_buttons * Originator: P. Topping * Date: 26th March 2003 * Function: PTA3 PTA2 PTD1 * ******************************************************************************/ void Read_buttons (void ((PTA & 0x08 ((PTA & 0x04 (PTD & 0x02) { ICGTR += 1; ...

Page 19

... HEX /* lower nibble in HEX /* display also in decimal */ /* leading 0 becomes space */ /* calc. freq. from delta /* display frequency /* leading 0 becomes space */ /* ESCI prescaller reg. /* upper three bits (+1) MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing */ */ */ */ */ */ */ */ */ */ ...

Page 20

... Freescale Semiconductor, Inc. AN2575/D /****************************************************************************** * * Function name: Format_line2 * Originator: P. Topping * Date: 26th March 2003 * Function: Format display of average frequency as a percentage of the * nominal frequency (0.1% resolution) and baud rate. * (the LIN temperature display is added by Read_LINtemp()) * ******************************************************************************/ void Format_line2 (void) { int remain; long total; volatile unsigned char BPD; ...

Page 21

... LIN data available /* yes, data available /* read sensor message /* and extract temp. byte /* negative ? /* yes,convert to positive */ /* but remember it wasn't /* no, remove offset and /* clear negative flag MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing */ */ */ */ */ */ */ */ */ */ ...

Page 22

... Freescale Semiconductor, Inc. AN2575/D bits = bits/2; tens = bits/10; units = bits%10; Line2[1] = units + 0x30; Line2[0] = 0x20; Line2[2] = 0x20; if (tens != 0) { Line2[0] = tens + 0x30; if (negative) { Line2[2] = 0xB0 else if (negative) { Line2[0] = 0xB0 For More Information On This Product, /* lose LS bit /* find tens digit /* and units digit ...

Page 23

... PTA = (PTA & 0x9F) | nibble * 0x20; PTC = (PTC & 0xFC) | nibble / 4; } MOTOROLA For More Information On This Product, /* read LCD busy status /* data, RS high /* command, RS low /* MS nibble /* clock display /* LS nibble /* clock display /* format bits for LCD /* interface MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing */ */ */ */ */ */ */ */ */ 23 ...

Page 24

... Freescale Semiconductor, Inc. AN2575/D /****************************************************************************** * * Function name: LCD_busy * Originator: P. Topping * Date: 10th February 2003 * ******************************************************************************/ unsigned char LCD_busy (void) { unsigned char busy; unsigned char wait; DDRA &= ~(0x60); DDRC &= ~(0x03); PTB &= ~(0x04); PTB |= 0x02; PTB |= 0x01; busy = (PTC & 0x02); PTB &= ~(0x01); ...

Page 25

... TBM flag set? /* yes, clear it /* Function set (8 bits) /* and clock /* wait and clock again /* and again /* Function set 4 bit mode */ /* 2 line display /* display off /* display high MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D Software Listing */ */ */ */ */ */ */ */ */ */ */ ...

Page 26

... Freescale Semiconductor, Inc. AN2575/D /****************************************************************************** * * Function name: TimerA0 * Originator: P. Topping * Date: 19rd March 2002 * Function: Timer A, channel 0 interrupt service routine * Read timer, subtract from previous value and save delta * in global "delta0" and in 16 result array "delta_buffer[]" * ******************************************************************************/ #pragma TRAP_PROC void TimerA0 (void) { unsigned char thigh ...

Page 27

... ICGTR *((volatile unsigned char *)0x0038) #define DDIV *((volatile unsigned char *)0x0039) #define DSTG *((volatile unsigned char *)0x003A) #define VECTF (void(*const)()) /* Vector table function specifier */ MOTOROLA For More Information On This Product, 24-01-02 MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D HC08EY16.h 27 ...

Page 28

... Freescale Semiconductor, Inc. AN2575/D vector.c #define VECTOR_C /****************************************************************************** * * Copyright (C) 2001 Motorola, Inc Functions: Vectors table for LIN08 Drivers with Motorola API * * Description: Vector table and node's startup for HC08. * The users can add their own vectors into the table, * but they should not replace LIN Drivers vectors. ...

Page 29

... TIMER B channel 0xFFF0 TIMER B channel 0xFFF2 TIMER A overflow /* 0xFFF4 TIMER A channel 0xFFF6 TIMER A channel 0xFFF8 CMIREQ /* 0xFFFA IRQ /* 0xFFFC SWI /* 0xFFFC SWI /* 0xFFFE RESET MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D vector ...

Page 30

... Freescale Semiconductor, Inc. AN2575/D slave.cfg #ifndef LINCFG_H #define LINCFG_H /****************************************************************************** * * Copyright (C) 2001 Motorola, Inc Functions: LIN Driver static configuration file for LIN08 Slave sample * with Motorola API * * Notes: * ******************************************************************************/ #if defined (HC08) /* This definition configures the ESCI Prescaler divide ratio #define LIN_SCIPRESCALER /* This definition configures the LIN bus baud rate. This value /* shall be set according to target MCU SCI register usage ...

Page 31

... Message Identifier configuration for LIN08 Slave sample * with Motorola API * * * Notes: * ******************************************************************************/ #define LIN_MSG_0A LIN_RECEIVE /* this string is not necessary - just as an example */ #define LIN_MSG_0A_LEN 2 #endif /* defined(LINMSGID_H)*/ MOTOROLA For More Information On This Product, /* standard length */ MC68HC908EY16 ESCI LIN Drivers Go to: www.freescale.com AN2575/D slave.id 31 ...

Page 32

... Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2003 AN2575/D Go to: www.freescale.com ...

Related keywords