AN2633 Freescale Semiconductor / Motorola, AN2633 Datasheet

no-image

AN2633

Manufacturer Part Number
AN2633
Description
LIN Drivers for SLIC Module on the MC68HC908QL4
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2633/D
Rev. 1, 3/2004
LIN Drivers for SLIC Module
on the MC68HC908QL4
By: Matt Ruff
Overview
Local Interconnect
Network (LIN)
8/16 Bit Systems Engineering
Austin, Texas
NOTE:
This application note describes three versions of a slave LIN driver developed
for the slave LIN interface controller (SLIC) module on the MC68HC908QL4
(QL4) microcontroller unit (MCU). The slave driver comes with the Motorola
QL4 LIN kit evaluation board, which also contains AN2573/D: LIN Kits LIN
Evaluating Boards, which demonstrates the functionality of the driver.
The slave driver also comes with the M68EVBQL4 evaluation board (EVB)
from Metrowerks, along with a compatible version of the application code for
the EVB. The software for the LIN kit, including this driver, can be downloaded
from the Motorola LIN website: http://motorola.com/semiconductors/LIN
LIN (local interconnect network) is a low-cost communication protocol often
used in automotive applications that do not require the bandwidth and
versatility of CAN. The LIN bus uses only a single data wire and can
communicate at speeds up to 20 kbps. A LIN network has a single master and
multiple slaves, so bus arbitration is not required.
The driver and application was developed from the LIN Specification Package.
(See
With the exception of mask set errata documents, if any other Motorola
document contains information that conflicts with the information in the device
data sheet, the data sheet should be considered to have the most current and
correct data.
Cyclone
This product incorporates SuperFlash
Freescale Semiconductor, Inc.
For More Information On This Product,
References
®
and MultiLink
Go to: www.freescale.com
for this and other useful resources.)
®
are registered trademarks of P&E Microcomputer Systems, Inc.
®
technology licensed from SST.
© Motorola, Inc., 2004

Related parts for AN2633

AN2633 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2633/D Rev. 1, 3/2004 LIN Drivers for SLIC Module on the MC68HC908QL4 By: Matt Ruff 8/16 Bit Systems Engineering Austin, Texas Overview This application note describes three versions of a slave LIN driver developed for the slave LIN interface controller (SLIC) module on the MC68HC908QL4 (QL4) microcontroller unit (MCU) ...

Page 2

... Freescale Semiconductor, Inc. AN2633/D SLIC Module The SLIC module automates many LIN bus functions, allowing more of the CPU and memory resources to be used for the user application. This application note compares CPU and memory usage details among timer-based, UART-based solutions, and SLIC-based solutions. ...

Page 3

... This also means that ROM devices are perfectly suited to be used without any nonvolatile memory at all, because they would never need to store a trim value. MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Autosynchronization Autobauding Go to: www.freescale.com AN2633/D SLIC Module Operation, Features, and Benefits 3 ...

Page 4

... Freescale Semiconductor, Inc. AN2633/D High-Speed The SLIC is also capable of high-speed operations without the need to change Communications and driver code. It will automatically synchronize to LIN messages 120 kbps Factory Programming (depending on CPU speed and filter settings). This is especially useful for downloading code in a factory programming environment. ...

Page 5

... UART solution. This further reduces the amount of MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, SLIC Module Operation, Features, and Benefits Driver. Go to: www.freescale.com AN2633/D CodeWarrior Project — 5 ...

Page 6

... Freescale Semiconductor, Inc. AN2633/D time spent inside the communications interrupt handlers. This time is valuable because other interrupts cannot be handled during this time. Hardware — LIN Kit Demo Board The LIN kit demo board is made from a QL4 with an added LIN interface, which consists of an MC33399 LIN transceiver and a 5-V regulator (an LT1121 chip) ...

Page 7

... MCU. LIN network activity would then cause a power-on reset (POR) and code will begin again from scratch. MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Figure 4. QL4 LIN Kit Board Go to: www.freescale.com AN2633/D Hardware — LIN Kit Demo Board 7 ...

Page 8

... Freescale Semiconductor, Inc. AN2633/D Hardware — M68EVB908QL4 Evaluation Board The QL4 evaluation board is made from a QL4 with an added enhanced LIN interface, which consists of an MC33661 enhanced LIN transceiver and a 5-V regulator (an LT1121 chip). The board can be programmed either using the RS-232 MON08 interface or a Cyclone/MultiLink tool. ...

Page 9

... Freescale Semiconductor, Inc. Figure 5. Schematic of M68EVB908QL4 Evaluation Board MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Hardware — M68EVB908QL4 Evaluation Board Figure 6. M68EVB908QL4 Evaluation Board Go to: www.freescale.com AN2633/D 9 ...

Page 10

... Freescale Semiconductor, Inc. AN2633/D The EVB does not support the regulator inhibit function by the physical layer, so this must be taken into account when using software that handles sleep mode. Care must be taken to ensure that the SLIC module is disabled before disabling the physical layer because recovery from sleep will not result in POR. ...

Page 11

... The SLCSV register value is loaded into the index register, then used as an offset into the jump table. The entries in the jump table point to service handler MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, CodeWarrior Project — Assembly Source Code Basic SLIC Driver Go to: www.freescale.com AN2633/D 11 ...

Page 12

... Freescale Semiconductor, Inc. AN2633/D subroutines which handle each SLCSV value accordingly. flow of the assembly based ISR with a SLCSV value of 0x2C (ID Received). 1 ENTER ISR AND LOAD slic_isr: SLCSV INTO INDEX REGISTER. jmptab:jmp JUMP TO ENTRY IN JUMP 2 TABLE FOR INTERRUPT SOURCE IN SLCSV. 3 JUMP DIRECTLY TO ...

Page 13

... MCU register definition header file (non-standard) ASM register definitions file Main application code MCU vector definitions Standard HC08 startup code MCU register data structure instantiations file (also non-standard) CodeWarrior parameter file for defining memory locations (ROM and RAM) in the MCU Go to: www.freescale.com AN2633/D Description 13 ...

Page 14

... Freescale Semiconductor, Inc. AN2633/D CodeWarrior Project — C Source Code Basic SLIC Driver In the C and ASM versions of this code, the same basic functions are performed. The C ISR, in this case, is just a few bytes smaller than the ASM ISR. This is primarily due to the efficiency of the CodeWarrior compiler and the fact that there is not much code to handle many of the different cases ...

Page 15

... The other files serve the same functions as they do in the assembly version project. MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, CodeWarrior Project — C Source Code Basic SLIC Driver 10. SLIC_LINdriver.c — contains the main driver code SLIC_LINdriver.h — header file for the driver Go to: www.freescale.com AN2633/D 15 ...

Page 16

... Freescale Semiconductor, Inc. AN2633/D CodeWarrior Project — C Source Code SLIC Driver with API The API version of the code is designed to provide essentially the same interface as the one contained in AN2599/D for QT/QY LIN slave drivers. As mentioned before, this driver is included in the LIN kit demo software, which can be downloaded free from the Motorola web site ...

Page 17

... LINmsg.c file. MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, CodeWarrior Project — C Source Code SLIC Driver with API below. vector 10) are set up properly, either in the vector.c file parameter file. Go to: www.freescale.com AN2633/D 17 ...

Page 18

... Freescale Semiconductor, Inc. AN2633/D • After message buffer storage has been created for all messages that will be recognized by the node, these must be included in a number of additional arrays. The order of the messages must be consistent in all arrays. The following three arrays are required: • ...

Page 19

... Message data OK, i.e. not overrun and not empty The message data has not changed since last read/written Message data has been updated The message data has not been read and was overwritten Go to: www.freescale.com AN2633/D Value 0x00 0x80 0x7F 0x16 ...

Page 20

... Freescale Semiconductor, Inc. AN2633/D LIN Message Status The message status is stored in the table called LinMsgStatus[]. When the LIN Flow driver is initialized all messages will get the status LIN_MSG_NODATA. Message status will change when the message is being sent, received, or updated. Table 5 message is received at a node. ...

Page 21

... Note: This function should be called before calling LIN_Wakeup(). Usage example: MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, CodeWarrior Project — C Source Code SLIC Driver with API status = LIN_GetMsg (0x99, MsgData); status = LIN_PutMsg (0x1A, MsgData); msgstatus = LIN_MsgStatus (0x1A); LIN_GotoRun(); Go to: www.freescale.com AN2633/D 21 ...

Page 22

... Freescale Semiconductor, Inc. AN2633/D LIN_Wakeup() LIN_Wakeup() issues the LIN wake-up signal, which consists of eight dominant bits (including start bit) followed by at least four recessive bits (including stop bit and a recessive pause). This function uses the WAKETX bit feature of the SLIC module to send a single wake-up signal on the bus ...

Page 23

... For More Information On This Product, Driver Performance — Timer, UART, and SLIC Compared Table 7. Error Descriptions Flag Set if there is a bit error when sending Set if there is a checksum error while receiving Table 8 shows the RAM and ROM usage of the various Go to: www.freescale.com AN2633/D Description 23 ...

Page 24

... Freescale Semiconductor, Inc. AN2633/D Version API QY/QT bit-banged drivers (1) AN2503/D QY/QT bit-banged drivers AN2599/D EY16 ESCI drivers (2) AN2575/D LINQL4-ASM LINQL4-C LINQL4-API 1. AN2503/D driver assumptions: MIN = external OSC, 9600 bps, no SLEEP mode, no parity check, no bit error checking MAX = internal OSC, 19200 bps, SLEEP, parity checking, and bit error checking enabled Each also has 7 messages defined, using 26 bytes of RAM 2 ...

Page 25

... Rx 120 Tx 19,230 9,615 97 Rx 106 Tx 19,230 9,615 12 19,230 9,615 19,230 9,615 2 19,230 9,615 19,230 Go to: www.freescale.com AN2633/D (1) CPU Usage CPU Speed (MHz) (2) Average Peak 14% (rx) 20% (tx) 193 µs 29% (rx) 40% (tx) 3.2 20% (rx) 20% (tx) 272 µs 38% (rx) 44% (tx) 2% (rx) 4% (tx) (4) 3 ...

Page 26

... Freescale Semiconductor, Inc. AN2633/D The difference in the number of interrupts serviced is best seen on an oscilloscope showing the ISR pulses. to service an 8-byte request message at 9600bps. Figure 12. 8-Byte LIN Request Message and Interrupt Handling for HC908QY4, HC908EY16, and HC908QL4 Channel 1 shows the LIN message as seen at the RX pin of the QL4 slave device ...

Page 27

... Filename: LINQL4-ASM/src/SLIC.asm ;/ Author: Matt Ruff ;/ Revision: 0 Functions: SLIC module routines ;/ ;/ History Description Notes: ;/ ;/_______________________________________________________________________________ MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Copyright (c) Motorola 2003 (v3.16) Comments ------------------------------------------------ Initial release - Go to: www.freescale.com AN2633/D References 27 ...

Page 28

... Freescale Semiconductor, Inc. AN2633/D Include 'QL4_registers_v0r2.inc' XDEF slic_isr XDEF slic_init MyData: SECTION SHORT XREF LINdata XREF LINID XREF BusOff XREF LINSleep MyCode: SECTION ;/+-----------------------------------------------------------------------------+ ;/| SLIC_Init - Initializes SLIC module ;/| ;/| Configures SLIC for: ;/| 1. LIN or BTM mode operation ;/| 2. Clock Operation in MCU Wait Mode ;/| 3. Receive filter prescaler adjustment for data rate ...

Page 29

... RX Buffer Full - Checksum OK - service handler ; RX Buffer Full - service handler ; --- uncomment to terminate service routine code ; Bit-Error - service handler ; --- uncomment to terminate service routine code ; RX Buffer Overrun - service handler ; --- uncomment to terminate service routine code ; Checksum Error - service handler Go to: www.freescale.com AN2633/D Appendix A: Software Listings — SLIC.asm 29 ...

Page 30

... Freescale Semiconductor, Inc. AN2633/D ; jmp exit_isr serve0x28: jmp exit_isr serve0x2C: lda SLCID cmp LINID bne next_id_1 lda LINdata sta SLCD0 lda #$00 sta SLCD1 lda #$C1 sta SLCDLC bra id_lookup_done next_id_1: not_found: lda #0 sta SLCDLC lda SLCC1 ora #mIMSG sta SLCC1 id_lookup_done: lda #0 ...

Page 31

... LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Appendix B – Software Listings – SLIC_LINdriver.c Copyright (c) Motorola 2003 (v3.16) Comments ------------------------------------------------ Initial release - // Temporary storage of SLIC buffer contents // Clear INITREQ bit in SLIC // Wait for INITACK to clear // Wait Clock Mode Go to: www.freescale.com AN2633 ...

Page 32

... Freescale Semiconductor, Inc. AN2633/D // SLCP = 0x80; SLCC2_SLCE = 1; } //+-----------------------------------------------------------------------------+ //| //| SLIC_ISR - Interrupt Service Routine //| //| Main handler for SLIC interrupts //| //+-----------------------------------------------------------------------------+ //____________________________SLIC_ISR_____________ #pragma TRAP_PROC void SLIC_ISR(void) { unsigned char temp_SLCSV = 0; char ID_found = 0; char temp = PTB_PTB0; temp_SLCSV = SLCSV; switch(temp_SLCSV) { case 0x00: //___________No Interrupts Pending__________________ break; case 0x04: //___________No Bus Activity________________________ BusOff++ ...

Page 33

... Set ID found flag // Write DLC code = RX, STANDARD CHECKSUM, 2 bytes #warning "ALPHA SAMPLE WORKAROUND" // Alpha sample workaround - write DLC = 0 before IMSG=1; // Set IMSG bit to ignore ID if not found! // reset ID_found // (should do anyway on re-entry into ISR) // Clear LINSleep flag-due to bus activity Go to: www.freescale.com AN2633/D 33 ...

Page 34

... Freescale Semiconductor, Inc. AN2633/D case 0x34: //___________Inconsistent-Synch-Field Error_______ break; case 0x38: //___________<reserved>___________________________ break; case 0x3C: //___________Wakeup_______________________________ break; } //___ end switch temp_SLCSV SLCS_SLCF = 1; } //_______________________________________________end_SLIC_ISR_______ ;***************************************************************************************** 34 LIN Drivers for SLIC Module on the MC68HC908QL4 // Clear SLIC interrupt flag For More Information On This Product, Go to: www ...

Page 35

... Freescale Semiconductor, Inc. MOTOROLA LIN Drivers for SLIC Module on the MC68HC908QL4 For More Information On This Product, Go to: www.freescale.com AN2633/D 35 ...

Page 36

... 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. 2004 AN2633/D Go to: www.freescale.com ...

Related keywords