AN2343 Freescale Semiconductor / Motorola, AN2343 Datasheet

no-image

AN2343

Manufacturer Part Number
AN2343
Description
HC908EY16 LIN Monitor
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2343/D
Rev. 0, 10/2002
HC908EY16 LIN Monitor
by Carl Culshaw
Introduction
Applications Engineering
Motorola, East Kilbride
With the continued increase in communications within the Automotive
environment, car manufacturers are resorting more and more to serial multiplex
bus systems. Controller Area Networks (CAN) continue to dominate, but many
applications are now being designed around the Local Interconnect Network
(LIN, reference 1).
To support this requirement, Motorola have designed a range of devices,
development boards and software applications to facilitate the migration to LIN.
This application note will focus on the following:
1. Hardware: HC908EY16 Sample Evaluation board
2. Software: Demonstration of LIN functionality
Freescale Semiconductor, Inc.
For More Information On This Product,
A pcb designed to ease new application development when using
the HC908EY16.
LIN Physical Interface
On board Programming
Use of the Metrowerks LIN Software Drivers
Monitoring LIN activity
Interfacing a LCD display with the Sample Evaluation Board
Go to: www.freescale.com
© Motorola, Inc., 2002

Related parts for AN2343

AN2343 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2343/D Rev. 0, 10/2002 HC908EY16 LIN Monitor by Carl Culshaw Applications Engineering Motorola, East Kilbride Introduction With the continued increase in communications within the Automotive environment, car manufacturers are resorting more and more to serial multiplex bus systems. Controller Area Networks (CAN) continue to dominate, but many applications are now being designed around the Local Interconnect Network (LIN, reference 1) ...

Page 2

... Freescale Semiconductor, Inc. AN2343/D Hardware: HC908EY16 Sample Evaluation board General Overview The HC908EY16 Sample board has been designed to allow the user an easy development path with the EY family of parts. Central to the board is the 44 pin HC908EY16. Each of the user pins (Ports A through E) is brought out to Single In Line Headers (P3 & P5). This is to allow the user to easily interface with much of the functionality of the EY16. On board LEDs (on Ports A & ...

Page 3

... Again, code can be executed and debugged using the CodeWarrior environment or the user may choose to disconnect the debugger and run from Flash. If the Cyclone is used, it should be configured to provide the on board clock. MOTOROLA For More Information On This Product, as appropriate) HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Hardware: HC908EY16 Sample Evaluation board 3 ...

Page 4

... Freescale Semiconductor, Inc. AN2343/D Software: Demonstration of LIN functionality General Overview The application developed on the HC908EY16 Sample board makes extensive use of the Metrowerks LIN drivers (reference 4). These drivers take care of the interfacing between the Enhanced SCI module of the EY16 with the LIN bus. ...

Page 5

... MOTOROLA For More Information On This Product, Software: Demonstration of LIN functionality 2 VDD VDD 4 PTB2 RS PTB1 5 RW PTB0 6 E Display 14 PTA6 D7 13 PTA5 D6 12 PTC1 D5 11 PTC0 D4 1 VSS VSS HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D VDD 3 10K - 5 ...

Page 6

... Freescale Semiconductor, Inc. AN2343/D References 1. LIN Protocol Specification, Version 1. Metrowerks CodeWarrior, www.metrowerks.com 3. MON08 Cyclone, www.pemicro.com! 4. Metrowerks LIN Drivers, www.metrowerks.com Acronyms UUT LIN CAN 6 For More Information On This Product, Unit Under Test Local Interconnect Network Controller Area Network HC908EY16 LIN Monitor Go to: www ...

Page 7

... For More Information On This Product, Idle count Yes No display No Yes Read Message 0x20 msg_update = 0x20 Display "Message 20" & 4 data bytes HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix A: Software Flowchart – Main Control loop Cursor Home (Top line, left) Clear Display Display "No Messages" 7 ...

Page 8

... Freescale Semiconductor, Inc. AN2343/D Appendix A: Software Flowchart – Initialisation Functions (1) Disable Interrupts 8 For More Information On This Product, Initialise UUT Disable ICG Turn ICG and Disable COP Select External Clock Option Enable high frequency option Initialise LIN Clear the ICGON drivers Bit in the ICGCR ...

Page 9

... Drive RW & RS Low Select 8 bit modeTx (Tx 0x03) Clock Display (Drive lo) Select 4 bit mode ( Turn display ON (Tx 0x0E) RTS HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Clear Display Yes Is display busy (Read D7)? No Drive RS & RW Low Clear command (Tx 0x01) Drive RS high RTS 9 ...

Page 10

... Freescale Semiconductor, Inc. AN2343/D Appendix B – Source Files ey16 giveaway.c /******************************************************************************* File Name : ey16 giveaway.c Originator : C. Culshaw Location : EKB Date Created : 8/3/02 Current Revision : 1.0 Function : Demonstrate LIN functionality using the EY16 Sample board Notes : Utilises the HC908EY16 as a LIN monitor. Software requires companion hardware, ’ ...

Page 11

... For More Information On This Product, // Used to store LIN received message data // // Disable COP watchdog // Disable interrupts // Configure part for high frequency // external crystal, ssb pull up resistor disabled // Initialise SCI / LIN registers HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 11 ...

Page 12

... Freescale Semiconductor, Inc. AN2343/D Function Name : Disable_ICG Engineer : C. Culshaw Date : 06/09/02 Parameters : None Returns : None Notes : The EY16 defaults to its internal clock generator (ICG). : For this application, disable the ICG & select the : external crystal *****************************************************************************/ void Disable_ICG(void) { unsigned short delay1 = 0; EY16ICG.icgcr.byte = 0x0A; ...

Page 13

... Set port A bits 5,6 (Display D4 & D5) to I/P // Set port C bits 0,1 (Display D6 & D7) to I/P // Display RS low // Display RW high // Display E high // Check display status // Display E low // Display RW low used to drive Register Select Line // Set port B bits 0,1,2 (Display RS, R/ O/P HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 13 ...

Page 14

... Freescale Semiconductor, Inc. AN2343/D while (Busy_Status() == 0x01); if (regsel == 1) { EY16PORT.ptb.byte |= 0x04; } else { EY16PORT.ptb.byte &= ~(0x04 shift data to allow high nibble to be written to display Display_Port(data/16); Clock_Display(); // mask & transmit low nibble Display_Port(data & 0x0F); Clock_Display(); asm NOP; } /**************************************************************************** Function Name : Write_Line2 Engineer : C. Culshaw Date ...

Page 15

... DisplayChar(2, nibble_pos++, hi_nibble); DisplayChar(2, nibble_pos++, lo_nibble); nibble_pos++; // Read busy status (Display D7) // Set port B bits 1&2 (Display RS & R/W) to O/P // Display RS low // Display RW low // Select DD RAM / cursor location // Read busy status (Display D7) // Display RS high HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 15 ...

Page 16

... Freescale Semiconductor, Inc. AN2343/D /**************************************************************************** Function Name : Initialise_Display Engineer : C. Culshaw Date : 06/09/02 Parameters : None Returns : None Notes : Display defaults to 8 bit data bus mode : First part of routine will change display bit : Once 4 bit is selected, data is transmitted to the : display in two 4 bit nibbles *****************************************************************************/ ...

Page 17

... Set port A bits 5,6 (Display D4 & D5) to O/P // Set port C bits 0,1 (Display D6 & D7) to O/P // Display D7 low // Display D6 low // Display D5 low // Display D4 low // Display D7 // Display D6 // Display D5 // Display D4 // Display D7 // Display D6 // Display D5 // Display D4 // Display D7 // Display D6 // Display D5 // Display D4 // Display D7 // Display D6 // Display D5 // Display D4 HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 17 ...

Page 18

... Freescale Semiconductor, Inc. AN2343/D case 0x05: EY16PORT.ptc.bit.ptc1 = 0x00; EY16PORT.ptc.bit.ptc0 = 0x01; EY16PORT.pta.bit.pta6 = 0x00; EY16PORT.pta.bit.pta5 = 0x01; break; case 0x06: EY16PORT.ptc.bit.ptc1 = 0x00; EY16PORT.ptc.bit.ptc0 = 0x01; EY16PORT.pta.bit.pta6 = 0x01; EY16PORT.pta.bit.pta5 = 0x00; break; case 0x07: EY16PORT.ptc.bit.ptc1 = 0x00; EY16PORT.ptc.bit.ptc0 = 0x01; EY16PORT.pta.bit.pta6 = 0x01; EY16PORT.pta.bit.pta5 = 0x01; break; case 0x08: EY16PORT.ptc.bit.ptc1 = 0x01; ...

Page 19

... Prepare display Cursor_Home(); // Display "Message "; for (count = 0; count < 8; count++) { MOTOROLA For More Information On This Product, // Display D7 // Display D6 // Display D5 // Display D4 // Put pcb & micro into default conditions// // Enable interrupts Display_Data(Message[count], 0x01); HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 19 ...

Page 20

... Freescale Semiconductor, Inc. AN2343/D } LIN_IdleClock(); // Determine if bus is active. if ((driver = LIN_DriverStatus()) != LIN_STATUS_IDLE Determine which message Id will be displayed // Tie Port C2 high or low to select message Read LIN message buffer if (msg_sel) { LIN_GetMsg (0x30, Message_30 switch (msg_update) { case 0x20: case 0x30: } msg_update = 0; } else { // No message has been seen on bus for > LIN_IDLETIMEOUT ...

Page 21

... Master node only SCI transmit ISR */ /* Timer Interface Module Channel 0 ISR */ /* ESCI receive ISR */ /* ESCI error ISR */ /* SWI ISR */ /* (used for Master node only) /* ESCI transmit ISR /* Timer Interface Module Channel 0 ISR HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files */ */ */ 21 ...

Page 22

... Freescale Semiconductor, Inc. AN2343/D /****************************************************************************** NODE STARTUP By default compiler startup routine is called. User is able to replace this by any other routine. ******************************************************************************/ #if defined(HICROSS08) #define Node_Startup _Startup extern void _Startup(); #endif /* defined(HICROSS08) */ #if defined(COSMIC08) #define Node_Startup _stext extern void _stext(); #endif /* defined(COSMIC08) */ /****************************************************************************** INTERRUPT VECTORS TABLE User is able to add another ISR into this table instead NULL pointer. ...

Page 23

... TIMER A channel (used for Master node only)*/ /* 0xFFF6 TIMER A channel 0xFFF6 TIMER A channel 0xFFF8 CMIREQ /* 0xFFFA IRQ /* 0xFFFC SWI /* 0xFFFC SWI /* 0xFFFE RESET HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ ...

Page 24

... Freescale Semiconductor, Inc. AN2343/D }; #endif /* defined(HC08EY16) */ #if defined(HICROSS08) #pragma CONST_SEG DEFAULT #endif /* defined(HICROSS08) */ #endif /* defined(HC08) */ slave.cfg #ifndef LINCFG_H #define LINCFG_H /****************************************************************************** * * Copyright (C) 2001 Motorola, Inc. * All Rights Reserved * * The code is the property of Motorola GSG St.Petersburg * Software Development * and is Motorola Confidential Proprietary Information The copyright notice above does not evidence any * actual or intended publication of such source code ...

Page 25

... This definition set the number of user-defined time clocks (LIN_IdleClock service calls), recognized as "no-bus-activity" condition. T|his number shall not be greater than 0xFFFF. */ #define LIN_IDLETIMEOUT 400u #endif /* defined (HC08) */ #endif /* !define (LINCFG_H) */ MOTOROLA For More Information On This Product, 0x04u*/ HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 25 ...

Page 26

... Freescale Semiconductor, Inc. AN2343/D slave.id #ifndef LINMSGID_H #define LINMSGID_H /****************************************************************************** * * Copyright (C) 2001 Motorola, Inc. * All Rights Reserved * * The code is the property of Motorola GSG St.Petersburg * Software Development * and is Motorola Confidential Proprietary Information The copyright notice above does not evidence any * actual or intended publication of such source code. ...

Page 27

... ENTRIES _vectab END INIT _Startup /* contains line replacing default _PRESTART*/ MAPFILE ON MOTOROLA For More Information On This Product, /* zero page*/ /* program data */ /* stack*/ /* program code & constants */ /* interrupt vectors (use your vector.obj) */ HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix B – Source Files 27 ...

Page 28

... Freescale Semiconductor, Inc. AN2343/D Appendix C – Header Files ey16port.h /**** Filename : EY16port.h Defines the port block as a datastructure Datastructure base address (out of reset) - EY16 : 0x0000 Written by Ross McLuckie (R38917) Revision history - 7/2/00 - Initial coding 8/1/02 - Modified for the HC908EY16 (TMcH) ****/ #ifndef EY16PORT_H //prevent duplicate includes ...

Page 29

... PTD0 0x01 //bit masks #define PTD1 0x02 typedef union uDDRA { tU08 byte; MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix C – Header Files 29 ...

Page 30

... Freescale Semiconductor, Inc. AN2343/D struct { tU08 ddra0 :1; //data direction bits (0:input;1:output) tU08 ddra1 :1; tU08 ddra2 :1; tU08 ddra3 :1; tU08 ddra4 :1; tU08 ddra5 :1; tU08 ddra6 :1; tU08 :1; //not used }bit; }tDDRA; #define DDRA0 0x01 //bit masks #define DDRA1 0x02 #define DDRA2 0x04 #define DDRA3 ...

Page 31

... DDRE0 0x01 //bit masks #define DDRE1 0x02 typedef struct //port control { volatile tPTA pta; //port A data register MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix C – Header Files 31 ...

Page 32

... Freescale Semiconductor, Inc. AN2343/D volatile tPTB ptb; //port B data register volatile tPTC ptc; //port C data register volatile tPTD ptd; //port D data register tDDRA ddra; //port A data direction register tDDRB ddrb; //port B data direction register tDDRC ddrc; //port C data direction register tDDRD ddrd ...

Page 33

... CMON 0x20 #define CMF 0x40 #define CMIE 0x80 typedef union uICGMR { tU08 byte; struct { tU08 n0 :1; //spi baud rate bits tU08 n1 :1; //mode fault enable MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix C – Header Files 33 ...

Page 34

... Freescale Semiconductor, Inc. AN2343/D tU08 n2 :1; //transmitter empty flag tU08 n3 :1; //mode fault flag tU08 n4 :1; //receiver overflow flag tU08 n5 :1; //error interrupt enable tU08 n6 :1; //receiver full flag tU08 :1; //not used }bit; }tICGMR; #define N0 0x01 //bit masks #define N1 0x02 #define N2 ...

Page 35

... MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix C – Header Files 35 ...

Page 36

... Freescale Semiconductor, Inc. AN2343/D ey16config.h /**** Filename : ey16config.h Defines the config registers as a datastructure base address (out of reset) - EY16 : 0x001E Written by Ross McLuckie (R38917) Revision history - 8/2/00 - Initial coding ****/ #ifndef EY16CONFIG_H //prevent duplicated includes #define EY16CONFIG_H #ifndef COMMON_H //prevent duplicated includes #include <common.h> ...

Page 37

... HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix C – Header Files 37 ...

Page 38

... Freescale Semiconductor, Inc. AN2343/D Appendix D – HC908EY16 Sample Board Schematic 38 For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com MOTOROLA ...

Page 39

... Freescale Semiconductor, Inc. Appendix E – Layout Top View MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix E – Layout Top View 39 ...

Page 40

... Freescale Semiconductor, Inc. AN2343/D Appendix E – Layout Bottom view 40 For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com MOTOROLA ...

Page 41

... Freescale Semiconductor, Inc. Appendix E – Layout Combined MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix E – Layout Combined 41 ...

Page 42

... Freescale Semiconductor, Inc. AN2343/D Appendix E – Layout Specification 42 For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com MOTOROLA ...

Page 43

... Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, HC908EY16 LIN Monitor Go to: www.freescale.com AN2343/D Appendix E – Layout Specification 43 ...

Page 44

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

Related keywords