AN2573 Freescale Semiconductor / Motorola, AN2573 Datasheet

no-image

AN2573

Manufacturer Part Number
AN2573
Description
LINkits LIN Evaluation Boards
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2573/D
Rev. 1, 11/2003
LINkits LIN Evaluation Boards
By Peter Topping
Introduction
CodeWarrior is a registered trademark of Metrowerks, Inc., a wholly owned subsidiary of Motorola, Inc.
This product incorporates SuperFlash
Motorola, East Kilbride
This application note describes the demonstration application that is
programmed into the LINkits evaluation boards. The LINkits boards comprise
two LIN masters (MC68HC9S12C32/D64 and MC68HC908GZ60) and four
slaves (MC68HC908GR60, MC68HC908EY16, MC68HC908QY4, and
MC68HC908QL4). These devices will be referred to as the 9S12C32,
9S12D64, GZ60, GR60, EY16, QY4, and QL4, respectively. At the time of
publication, QL4 silicon was unavailable so this board is not described.
The application runs using either of the masters and any combination of as
many as 16 slaves (maximum of 4 slaves of any one type). This is achieved by
using different default LIN IDs for each type of slave and by allowing this ID to
be easily changed to any one of the three other IDs for that particular slave. If
no more than one slave of any type is in use, no modification from the default
IDs is necessary.
In order to retain versatility in the selection of the MCUs used for the master
and slave nodes, the boards are available separately. There is also an
accessory kit that includes a 500-mA power supply, an RS-232 cable, and a CD
containing the documentation and software. This includes the application
programs and the LIN drivers for each node, allowing users to develop their
own LIN applications using the LINkits boards. The RS-232 cable is required to
connect the LINkits board to a PC running the Metrowerks’ CodeWarrior
development environment. This cable is not part of the programmed
demonstration application.
Each slave has four LEDs whose states can be controlled by a single
push-button switch. The resulting four bits of data is returned to the master and
displayed on four of its eight LEDS. The other four LEDs on the master are
used to indicate the slave type and ID. Two LEDs show the slave type (GR, EY,
QY, or QL) and the other two correspond to the four IDs allocated to that
particular type. If more than one slave is connected, the master’s display cycles
Freescale Semiconductor, Inc.
®
For More Information On This Product,
technology licensed from SST.
Go to: www.freescale.com
© Motorola, Inc., 2003
®

Related parts for AN2573

AN2573 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2573/D Rev. 1, 11/2003 LINkits LIN Evaluation Boards By Peter Topping Motorola, East Kilbride Introduction This application note describes the demonstration application that is programmed into the LINkits evaluation boards. The LINkits boards comprise two LIN masters (MC68HC9S12C32/D64 and MC68HC908GZ60) and four slaves (MC68HC908GR60, MC68HC908EY16, MC68HC908QY4, and MC68HC908QL4) ...

Page 2

... Freescale Semiconductor, Inc. AN2573/D round all those present on the bus. The sending of header frames from the master can also be switched off to demonstrate the slaves’ ability to enter low-power sleep mode in the absence of LIN activity (not applicable to the QY4 slave). NOTE: With the exception of mask set errata documents, if any other Motorola ...

Page 3

... Given the different resources and pin-outs of the various MOTOROLA For More Information On This Product, shows the main circuit diagram of the MC68HC908EY16 LINkits slave Figure LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D Hardware Table 1 1. The complete circuit diagram also 3 ...

Page 4

... Freescale Semiconductor, Inc. AN2573/D devices, the pin-outs of P1 and P2 are as consistent as possible across all the boards. The masters have additional pins available on a third 20-way connector, P3. The basic circuit diagram of a LIN slave node is very simple. It comprises the MCU, the LIN physical interface, and a 5-volt regulator. In this case, the ...

Page 5

... OSC1 pin. This jumper is also required when using the Cyclone/MultiLink interface with an external clock selected. Cyclone MOTOROLA For More Information On This Product, ® and MultiLink ® are registered trademarks of P&E Microcomputer Systems, Inc. LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D Hardware ® ® /MultiLink 5 ...

Page 6

... Freescale Semiconductor, Inc. AN2573/D Master Software The flow chart of the master code is shown in at the end of this document. After MCU and LIN driver initialization, the slide switch on the PCB is checked to see if LIN activity should be active. If not, a continuous sweeping LED display is enabled. If, however, LIN activity is required, the while(1) loop in the master’ ...

Page 7

... AND CLEAR FLAG ALREADY ACTIVE DISPAY DATA AND ID LOOP DELAY Figure 2. MC68HC9S012C32 Master Software Flow Chart LINkits LIN Evaluation Boards Go to: www.freescale.com Master Software NO IDLE DISPLAY ? NO LIN ACTIVITY YES LastID ? NO YES ? NO ? YES NO “NEW NODE” DISPLAY ? AND SET FLAG YES NEXT ID AN2573/D 7 ...

Page 8

... Freescale Semiconductor, Inc. AN2573/D Slave Software The accompanying code listing for First, the CONFIG, I/O, and timer registers are initialized. In the case of the EY16, the ICG initial trimming value is also written to the ICGTR register. In the demonstration application, this has been entered manually and the code recompiled for each board ...

Page 9

... INCREMENT COUNT, TOGGLE “TICK” READ PUSH-BUTTON SWITCH AND TAKE APPROPRIATE ACTION (FIGURE MODE ? YES NO COUNT BIT 4 HIGH ? YES WRITE ID TO LEDS ADD RESPOND FIELD TO THE LIN MESSAGE WITH SELECTED ID LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D Slave Software ALL LEDS OFF 9 ...

Page 10

... Freescale Semiconductor, Inc. AN2573/D INCREMENT DATA NO DATA = 16 ? YES DATA = 1 Figure 4. MC68HC908EY16 Slave Software Push-Button Flow Chart 10 READ PUSH-BUTTON NO SAME ? YES NO DEBOUNCED ? YES NO PUSH-BUTTON PRESSED ? YES NO ID MODE ? YES INCREMENT YES INCREMENT KEYCOUNT COUNTER NO MODECOUNT ? YES NO PUSH-BUTTON PRESSED ? YES ...

Page 11

... The second is slave.id, which defines the messages to be acted upon by this node. The use of these files is described in the user’s manual (see References). MOTOROLA For More Information On This Product, LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D CodeWarrior Project Figure 5. The folder 11 ...

Page 12

... Freescale Semiconductor, Inc. AN2573/D The sample directory also contains the projects .prm, .mcp, and .ini files and an include file slave.h for register definitions not already defined by the LIN drivers. Again, the QY4 is slightly different. It does not have the vector.c file but uses its .prm file to define the vectors. It also does not have the slave.cfg or slave.id file ...

Page 13

... Master Request Command Frame (ID Field value '0x3C'). * * Returns: never return * * Notes: * *****************************************************************************/ void LIN_Command() { while( MOTOROLA For More Information On This Product, /* errors counter */ /* messages counter */ /* transmited data */ /* received deta */ /* time from real time counter */ LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings 13 ...

Page 14

... Freescale Semiconductor, Inc. AN2573/D /***************************************************************************** * Function: Delay * * Description: Initialise RTI for use in Delay() function * * * Returns: none * * Notes *****************************************************************************/ void InitDelay(unsigned int busfreq) { switch (busfreq) { case 40000: RTICTL = 0x44; case 32000: RTICTL = 0x60; case 16000: RTICTL = 0x50; case 12000: RTICTL = 0x32; case 8000: case 4915: case 4000: default: break ...

Page 15

... Delay(125); strip = strip<< /***************************************************************************** * Function: LostNode * * Description: Flash LEDs in sequence high to low Returns: none MOTOROLA For More Information On This Product, Uses real time interrupt function - must be initialised elsewhere to give 1ms timeouts LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings 15 ...

Page 16

... Freescale Semiconductor, Inc. AN2573 Notes: * *****************************************************************************/ void LostNode() { char i; unsigned char strip = 0x80; for ( < 8; i++) { PORTB = ~strip; Delay(125); strip = strip>> /***************************************************************************** * Function: LINActive * * Description: Returns only if master switch has enabled LIN * * Returns: none * * Notes: * *****************************************************************************/ void LINActive Check switch position */ PERJ = 0x40; ...

Page 17

... LIN_RequestMsg( 0x17 ); /* Wait for message processing */ do { ret = LIN_DriverStatus(); } while( ret & LIN_STATUS_PENDING ); /* Check sent message status */ ret = LIN_MsgStatus( 0x17 ); if ( ret != LIN_OK ) { ErrCount = 1; while( MOTOROLA For More Information On This Product, LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings 17 ...

Page 18

... Freescale Semiconductor, Inc. AN2573 Schedule Loop */ while Check/Enable LIN interface */ LINActive(); /* Slave received messages - cycle here */ for ( < messageList; i++) { /* Send a request for message */ ret = LIN_RequestMsg( idList[ Wait for message processing */ do { ret = LIN_DriverStatus(); } while( ret & LIN_STATUS_PENDING ); /* Check received message status */ ret = LIN_MsgStatus( idList[i] ) ...

Page 19

... For More Information On This Product, (*(( volatile unsigned char*) (address))) (*(( volatile unsigned int*) (address))) /* PORTA moved */ /* PORTB moved */ /* DDRA moved */ /* DDRB moved */ /* CRGFLG moved */ /* CRGINT moved */ /* RTICTL moved */ /* PTJ moved */ /* PERJ moved */ LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings 19 ...

Page 20

... Freescale Semiconductor, Inc. AN2573/D master.id #ifndef LINMSGID_H #define LINMSGID_H /****************************************************************************** * * Copyright (C) 2003 Motorola, Inc. * All Rights Reserved * * Filename: $RCSfile: /net/sdt/vault-rte/cvsroot/lin/release/hc12star/sample/master/master.id Author: $Author: kam $ * Locker: $Locker State: $State: Exp $ * Revision: $Revision: 1 Functions: Message Identifier configuration for LINS12 LINkits Master sample * * * History: Use the RCS command log to display revision history * information ...

Page 21

... Use the RCS command log to display revision history * information Description: Example file that can be modified by the user Notes: * MOTOROLA For More Information On This Product standard length */ LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings 21 ...

Page 22

... Freescale Semiconductor, Inc. AN2573/D ******************************************************************************/ /* CPU bus freq = 8 MHz */ /* SCI (LIN) freq = 9.6 Kbit */ /* This definition set the number of user-defined timer clocks (LIN_IdleClock service calls), recognized as "no-bus-activity" condition. This number shall not be greater than 0xFFFF. */ #define LIN_IDLETIMEOUT /* This definition configures the LIN bus baud rate. ...

Page 23

... User is able to add another ISR into this table instead NULL pointer. ******************************************************************************/ #if !defined(NULL) #define NULL (0) #endif /* !defined(NULL) */ #undef LIN_VECTF MOTOROLA For More Information On This Product, /* SCI interrupt routine /* Timer channel 0 interrupt routine */ /* LIN Startup routine /* LIN Startup routine LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings */ */ */ 23 ...

Page 24

... Freescale Semiconductor, Inc. AN2573/D #if defined(CW12) #define LIN_VECTF ( void ( *const near )( ) ) #endif /* defined(CW12) */ #if defined(COSMIC12) #define LIN_VECTF ( void *const ) #endif /* defined(COSMIC12) */ #if defined(CW12) #pragma CONST_SEG VECTORS_DATA #endif /* defined(CW12) */ #if defined(CW12) void near ( * const near _vectab #endif /* defined(CW12) */ #if defined(COSMIC12) void @near ( * const @near _vectab #endif /* defined(COSMIC12) ...

Page 25

... Real Time Interrupt /* 0xFFF2: IRQ /* 0xFFF4: XIRQ /* 0xFFF6: SWI /* 0xFFF8: instr trap /* 0xFFFA: cop fail /* 0xFFFC: cop clock fail /* 0xFFFE: Reset LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC9S12C32 Master Software Listings */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ ...

Page 26

... Freescale Semiconductor, Inc. AN2573/D MC68HC908EY16 Slave Software Listings /****************************************************************************** * * Copyright (C) 2003 Motorola, Inc Filename: $RCSfile: /net/sdt/vault-rte/cvsroot/lin/release/hc12star/sample/slave/slave.c Author: $Author: snl $ * Locker: $Locker State: $State: Exp $ * Revision: $Revision: 1 Functions: Sample application for LIN08EY16 LINKits Slave Driver * * History: Use the RCS command log to display revision history * information ...

Page 27

... MCU /* used for LED flashing /* toggle tick output /* read button on PTA4 /* update LEDs on PTB0-3 /* send LIN response msg. LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC908EY16 Slave Software Listings * * * * * */ */ */ ...

Page 28

... Freescale Semiconductor, Inc. AN2573/D * and to decide if the same state has been present long * enough (3 seconds) for a mode change. In each mode the * appropriate increment (data or ID) takes place the switch status changes the counter is reset. * ******************************************************************************/ void Read_button (void) { unsigned char key; key = PTA & 0x10; ...

Page 29

... MOTOROLA For More Information On This Product mode LED display /* ID mode flash, LEDs off */ /* normal mode so /* drive LEDs with data /* LIN response to ID21 /* LIN response to ID22 LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D MC68HC908EY16 Slave Software Listings * * * * * * * */ */ ...

Page 30

... Freescale Semiconductor, Inc. AN2573/D LIN_PutMsg (0x23, LIN_data); break; case 3: LIN_PutMsg (0x20, LIN_data); break /****************************************************************************** * Function: LIN_Command * Description: User call-back. Called by the driver after transmission or * reception of the Master Request Command Frame (ID: 0x3C). ******************************************************************************/ void LIN_Command() { while( HC08EY16.h (Register Definitions for the MC68HC908EY16) /****************************************************************************** * * Copyright (C) 2003 Motorola, Inc. ...

Page 31

... For More Information On This Product, HC08EY16.h (Register Definitions for the MC68HC908EY16) (*(( volatile unsigned char*) (address))) (*(( volatile unsigned int*) (address))) /* PORT A */ IOBYTE(0x0001) /* PORT B */ IOBYTE(0x0002) /* PORT C */ IOBYTE(0x0003) /* PORT D */ IOBYTE(0x0008) /* PORT E */ IOBYTE(0x0004) /* DDR A */ IOBYTE(0x0005) /* DDR B */ IOBYTE(0x0006) /* DDR C */ IOBYTE(0x0007) /* DDR D */ IOBYTE(0x000A) /* DDR E */ LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D 31 ...

Page 32

... Freescale Semiconductor, Inc. AN2573/D slave.id (LIN Message ID File) #ifndef LINMSGID_H #define LINMSGID_H /****************************************************************************** * * Copyright (C) 2003 Motorola, Inc. * All Rights Reserved * * Filename: $RCSfile: /net/sdt/vault-rte/cvsroot/lin/release/hc12star/sample/master/master.id Author: $Author: kam $ * Locker: $Locker State: $State: Exp $ * Revision: $Revision: 1 Functions: Message Identifier configuration for LIN08 LINkits Slave sample ...

Page 33

... Selects 9600 baud for a nominal 4.9152 MHz clock (ICGMR=64) #define LIN_BAUDRATE /* Enable ESCI (fractional divide prescaler) baudrate synch. #define LIN_SYNC_SLAVE MOTOROLA For More Information On This Product, HC08EY16.h (Register Definitions for the MC68HC908EY16 0x60u /* divide by 4 0x00u 0x01u LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573 ...

Page 34

... Freescale Semiconductor, Inc. AN2573/D /* The following numbers assume that the ESCI prescaller = 1 /* Selects 9600 baud rate if using a 4.9152MHz crystal //#define LIN_BAUDRATE /* Selects 9600 baud rate if using an 8.000MHz crystal //#define LIN_BAUDRATE /* Selects 9600 baud rate if using a 16.000MHz crystal //#define LIN_BAUDRATE /* Selects 9600 baud rate if using a 32.000MHz crystal ...

Page 35

... HC08EY16.h (Register Definitions for the MC68HC908EY16) /* ESCI receive ISR /* ESCI error ISR /* Timer Module A Channel 0 ISR /* Timer Module A Channel 1 ISR /* Timer Module B Overflow ISR /* SWI ISR /* CW08 compiler startup routine declaration */ /* Cosmic compiler startup routine declaration /* vectors segment declaration */ */ LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573 ...

Page 36

... Freescale Semiconductor, Inc. AN2573/D /***************************************************************************/ /* /* /* /* These vectors are appropriate for the 2L31N mask set of the /* MC68HC908EY16 and all subsequent versions Older mask sets, e.g. 0L38H, 1L38H, 0L31N and 1L31N had a fault /* in their interrupt vector table and hence in the priorities. /* For these older mask sets the order of the SCI vectors was: ...

Page 37

... Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, HC08EY16.h (Register Definitions for the MC68HC908EY16) LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D 37 ...

Page 38

... Freescale Semiconductor, Inc. AN2573/D 38 LINkits LIN Evaluation Boards For More Information On This Product, Go to: www.freescale.com MOTOROLA ...

Page 39

... Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, HC08EY16.h (Register Definitions for the MC68HC908EY16) LINkits LIN Evaluation Boards Go to: www.freescale.com AN2573/D 39 ...

Page 40

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

Related keywords