Home

Application Notes - Freescale Semiconductor

image

Contents

1. Y READ SLIDE SWITCH Y LIN ENABLED gt YES IDLE DISPLAY NO LIN ACTIVITY yo LastiD NO Y SEND HEADER FRAME Y CHECK LIN DRIVER STATUS NO WAS ACTIVE NO T 4 YES Y Y PENDING 2 YES NO Y RESPONSE yo YES Y LOST NODE DISPLAY AND CLEAR FLAG GET DATA FROM SLAVE Y ALREADY ACTIVE gt n YES y NEW NODE DISPLAY AND SET FLAG DISPAY DATA AND ID y LOOP DELAY y NEXT ID Figure 2 MC68HC9S012C32 Master Software Flow Chart LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor Slave Software 5 Slave Software The accompanying code listing for Figure 3 is listed in back of this document First the CONFIG and timer registers are initialized In the case of the EY 16 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 but in volume applications this value could be stored in FLASH and transferred to ICGTR at the start of code execution When all the required registers have been initialized a while 1 loop is entered Execution of this loop is timed by the timebase module TBM on the GR60 and EY 16 Because the QY4 does not have a TBM m
2. define IOBYTE address volatile unsigned char address define IOWORD address volatile unsigned int address Registers undefined in standard LIN drivers define PORTA IOBYTE Ox1000 PORTA moved define PORTB Ox1001 PORTB moved define DDRA IOBYTE Ox1002 DDRA moved define DDRB 0x1003 DDRB moved define CRGFLG IOBYTE 0x1037 CRGFLG moved define CRGINT IOBYTE 0x1038 CRGINT moved define RTICTL 0x103B RTICTL moved define PTJ IOBYTE 0x1268 PTJ moved define PERJ Ox126C PERJ moved LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 17 MC68HC9S12C32 Master Software Listings Appendix B Master id 1 LINMSGID H define LINMSGID H BRK k k k k k k k k k k k k k k k k k K k k k a K k k Sk Sk ke e a a K K kk Sk K KOR R K K a a R K K KOR R K KOR R K K R a a K R KOR R ke ke a R K KO ke RK Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample master master id v Author SAuthor kam 5 Locker SLocker 5 State State Exp Revision Revision 1 3 5 Functions Message Identifier configuration for LINS12 LINkits Master sample History Use the RCS command log to display revision history information Description Notes ke k k k k
3. if defined 8 define LIN VECTF void const void const vectab endif defined COSMICO8 Hif defined HCO8EY16 LINkits LIN Evaluation Boards Rev 2 32 Freescale Semiconductor HCO8EY16 h Register Definitions for the MC68HC908EY16 BORK RR k kk KR k k k k k k k k k k k k k k k k KK k k k k KR a a k k k k k k k k k k a a k k k kk k a a a a a KR ke kk kk kkk ke kx HCO8EY16 These vectors are appropriate for the 2L31N mask set of the MC68HC908EY16 and all subsequent versions e Older mask sets e g 0L38H 1L38H OL31N 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 SCI Error ISR OxFFEG ESCI error SCI Transmit ISR OxFFE8 ESCI transmit SCI Receive ISR OxFFEA ESCI receive All other vectors are unchanged BRR RR KKK KR k k k k k k k k k k k k k k k a a a a k k Sk KK a k k k k k k k k k k k k k k k k k kk kk a a KR ke a a a ee ke ke ke x LIN VECTF NULL OxFFDC Timebase LIN VECTF NULL OxFFDE SPI transmit LIN VECTF NULL OxFFEO SPI receive LIN VECTF NULL OxFFE2 ADC LIN VECTF NULL OxFFEA Keyboard 1 defined MASTER used for Master node only LIN VECTF LIN ISR SCI Transmit OXFFE6 ESCI transmit endif defined
4. 1 yes change to ID mode else no not pressed mode 0 so back to normal mode Read_button P Topping 19th June 2003 The port line is read and its level compa it was the previous time through the loop same the counter keycount is used for and to decide if the same state has been red with what If it is the debounce 80ms present long enough 3 seconds for a mode change In appropriate increment data or ID takes If the switch status changes the counter id each mode the place is reset k ce k k k k k k k k k k k k k k k k k k k k k k k k k 1k k k KEK KEK k k k k k k k k k LINkits LIN Evaluation Boards Rev 2 TS OR SRU SD xj 7 f Freescale Semiconductor 25 De Sa ee a lt wCa sss rc MC68HC908EY16 Slave Software Listings else keycount 0 no different so reset key last key count and save status BORK RR RRR KR KR RK KR KK RK a a a a a a RR e a ke ke ke ke ke k RK or the flashing ID 0 21 1 22 2 23 3 20 Function name LED display xd Originator P Topping m Date 19th June 2003 Function According to mode the LEDs display the 4 bit data field k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k KEK KKK k k k k k k k k KKK 1k k k k k k k k k k k k k k k k k k k k k k k k 1 void LED_display vo
5. Out of reset each slave responds with two bytes of data using its default ID When in normal mode not ID configuration mode push button increments the LEDs through a binary cycle of 1 15 skipping zero This 4 bit number is displayed on the slave s LEDs and also on the top rightmost four bits of the master s LED display It is transferred to the master using the lower four bits of the first data byte of the slave s response The simple user interface uses a single push button switch and four LEDs and it allows the ID to be changed to any of the three configurable IDs or back to the default ID This configuration mode is entered by holding the button down for three seconds In this mode the LEDs flash and indicate the current ID The button then allows cycling through the four configurable IDs first LED for ID xx xx01 second for xx10 third for xx xx11 and fourth for xx xx00 If the button 15 not pressed for three seconds the mode returns to normal The sleep feature of the boards can be seen by switching off the master s LIN activity while the slaves are connected and running After five seconds the boards GR60 and EY16 only will go to sleep as represented by all the LEDs switching off This feature is not supported by the QY4 slave The allocation of the four alternative IDs for each slave type shown in Table 1 allows as many as eight slaves of one type to be used without reallocating any other IDs These alternativ
6. busfreq indicates the bus operating frequency in KHz K K a k k k k k k k k k k k k k k k k k k k k k k K k K KOK K K k KOR K K a a K K k R R K k KOR R K K KOR R k KOR R R K R R R k k ke ke ke ke ke R R K K x void InitDelay unsigned int busfreq Switch busfreq case 40000 RTICTL 0 44 break case 32000 RTICTL 0x60 break case 16000 RTICTL 0x50 break case 12000 RTICTL 0x32 break case 8000 RTICTL 0x40 break case 4915 RTICTL 0x14 break case 4000 RTICTL 0x30 break default break Initialise RTI interrupt CRGINT 0x80 BRR RR KK RRR RR RK RR KR RK KK RRR RK RR KK RR RR RK RR RR RR RRR eoe e ke RK RK KKK Function RTI_ISR Description Handle RTI ISR Add tick to time LINkits LIN Evaluation Boards Rev 2 12 Freescale Semiconductor oo eee MC68HC9S12C32 Master Software Listings Returns none Notes BR k k k k k k k k k k k k k k k k k a ke k k a a k k ck kk K K KOK K K K KOR K K KOR OR K R a a kk R R R R R k R k OR R K a R R K K pragma TRAP PROC void RTI ISR void Time Clear RTI flag CRGFLG 0x80 BRR RR KKK KR KK RR KR RK RK KK a a RK a a RR RR KR RRR RR RK RR e ke ke RR KK RK Function Delay Description Simple delay routine Delay for n ms Returns after n ms Notes Uses real time interrupt function must be initialised elsew
7. 0x0036 0x0037 LINkits LIN Evaluation Boards Rev 2 PORT PORT PORT PORT PORT DDR DDR DDR DDR DDR m g o D gt volatile unsigned char volatile unsigned int xf xf xf EN A address address 28 Freescale Semiconductor HCO8EY16 h Register Definitions for the MC68HC908EY16 define ICGTR IOBYTE 0x0038 define DDIV IOBYTE 0x0039 define DSTG 0x003A Appendix E Slave id LIN Message ID File ifndef LINMSGID H define LINMSGID H BORK RK a a RR RR RK RR KK RK a KR KR RRR a a a a KR a a RR RR RRR RR k k KK KKK k k Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample master master id v 5 Author SAuthor kam Locker SLocker 5 State SState Exp Revision SRevision 1 3 Functions Message Identifier configuration for LINO8 LINkits Slave sample History Use the RCS command log to display revision history information Description Notes k k k k k k k k k k k k k k k k k k ke ke KR KOK K K K KOR K K KOR R K K a a K K KOR R K R R R KOR R R k k OR RR k ke R KOR R R K x define LIN MSG 20 LIN SEND UPDATED define LIN MSG 21 LIN SEND UPDATED define LIN MSG 22 LIN SEND UPDATED define LIN MSG 23 LIN
8. MASTER dif defined SLAVE LIN VECTF NULL OxFFEG ESCI transmit endif defined SLAVE LIN VECTF LIN ISR SCI Receive OxFFE8 ESCI receive LIN VECTF LIN ISR SCI Error OxFFEA ESCI error LIN VECTF NULL OxFFEC TIMER B overflow LIN VECTF NULL OxFFEE TIMER B channel 1 LIN VECTF NULL OxFFFO TIMER B channel 0 LIN VECTF NULL OxFFF2 TIMER A overflow LIN VECTF NULL 4 TIMER A channel 1 LIN VECTF NULL OxFFF6 TIMER A channel 0 LIN VECTF NULL OxFFF8 CMIREQ LIN VECTF NULL OxFFFA IRQ LIN VECTF BREAK Command OxFFFC SWI LIN VECTF NULL OxFFFC SWI LIN VECTF Node Startup OxFFFE RESET endif defined HCO8EY16 Hif defined 08 pragma CONST_SEG DEFAULT endif defined CWO8 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 33 How to Reach Us Home Page www freescale com E mail support Qfreescale com USA Europe or Locations Not Listed Freescale Semiconductor Technical Information Center CH370 1300 N Alma School Road Chandler Arizona 85224 1 800 521 6274 or 1 480 768 2130 support freescale com Europe Middle East and Africa Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen Germany 44 1296 380 456 English 46 8 52200080 English 49 89 92103 559 German 33 1 69 35 48 48 French support freescale com Japan Freesc
9. Pulse acc B overf Down Counter overf Port H Port J ATD ATD SCI SCI SPI Pulse Pulse Timer Timer Timer Timer Timer Timer Timer Timer Timer acc input acc A overf Overflow C C C C C C C hannel hannel hannel hannel hannel hannel HNLW UO hannel hannel 0 LINkits LIN Evaluation Boards Rev 2 x x x x w 7 7 x x x xA x ee x n 22 Freescale Semiconductor MC68HC908EY16 Slave Software Listings LIN VECTF NULL OxFFEE Timer Channel 0 endif defined SLAVE LIN VECTF RTI ISR OxFFFO Real Time Interrupt LIN VECTF NULL OxFFF2 TRQ LIN VECTF NULL OxXFFF4 XIRQ LIN VECTF NULL OxFFF6 SWI LIN VECTF NULL OxFFF8 instr trap LIN VECTF NULL OxFFFA cop fail LIN VECTF NULL OxFFFC cop clock fail LIN VECTF LIN Startup OxFFFE Reset endif defined C32 1 defined CW12 pragma CONST SEG DEFAULT endif defined CW12 9 MC68HC908EY16 Slave Software Listings BORK k k k k k k k k k k k k k k k k e e k k k a a k k Sk ke ke K k a a a K a a Sk K Sk ke R K k KOR R K K KOR R K KOR R K K R R R a R R K R R R K k KOR K K Copyright C 2003 Motorola Inc All Rights Reserved Fil
10. R R R R k e R ke R OR R KOR R R K K LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 23 MC68HC908EY16 Slave Software Listings include slave h include lt linapi h gt define debounce 4 define modecount 224 unsigned char data 1 unsigned char ID 0 unsigned char key last unsigned char count unsigned char mode unsigned char LIN data 2 int keycount void Read button void void LED display void void LIN response void 13 3ms x 4 1 67ms 13 3ms x 22441 3s BRR KR KR KK RK e RK RK RK kk ke ke KK a RRR RRR RR RR RK KK k k k Function name Main Originator P Topping Date 18th June 2003 Function Loop at 75Hz Switch off if no LIN activity for 5s 375 ck ck k k k k k k k k k k k k k k k k k k k k k K K K k K KOK k K KOK K k k KOR K K KOR R K K R R K K R K R R R R R KOR R R ke R ke ke R R R e R R R void main void CONFIG1 0x01 dissable COP CONFIG2 0x45 slow clock for TBM ICGMR 64 ICG nominal 19 6608 MHz DDRA 0x00 button on A4 DDRB Ox3F LEDS on B0 3 LPI on B5 DDRC 0x80 MCLK on C2 tick on B4 PTB 0x20 enable MC33399 LPI 0x20 by 262144 for 75Hz TBCR 0x22 19 661MHz enable TBM ICGTR 158 insert trim value here asm cli enable interrupts LIN Init initialise LIN drivers while
11. SEND UPDATED define LIN MSG 20 LEN define LIN MSG 21 LEN define LIN MSG 22 LEN define LIN MSG 23 LEN non standard length non standard length non standard length non standard length P E P N N N N endif defined LINMSGID_ H Appendix F Slave cfg LIN Configuration File ifndef LINCFG_H define LINCFG_H BORK k k k k k k k k k k k k k k k k k k k k k K K k k k K K K k a a K K KOR K K KOR R K K KOR R K K KOR OR K KOR R K K k KOR K R RR KOR R KK KOR R K LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 29 HCO8EY16 h Register Definitions for the MC68HC908EY16 Copyright C 2003 Motorola Inc All Rights Reserved Description It is allowed to modify by the user Notes External MCU frequency 8 000MHz SCI Baud rate 9600 This definition configures the ESCI Prescaler divide ratio define LIN SCIPRESCALER 0x60u divide by 4 This definition configures the LIN bus baud rate This value shall be set according to target MCU SCI register usage HCO8EY16 the 8 bit SCBR value will be masked by 0x37 The following numbers assume that the ESCI prescaller 4 Selects 9600 baud for a nominal 2 4576 MHz clock ICGMR 32 define LIN BAUDRATE 0x00u Selects 9600 baud for a nominal 4 9152 MHz clock ICGMR 64 define LIN BAUDRATE OxO1lu Enable ESCI fractional divide prescaler baudrate synch define LIN SYNC SLA
12. 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 it uses LINmsg c for defining messages 5 28 LINEY16 28 hc08 inc J man 1 28 sample 2 bin 5 08 sample Data a LINOSEY16 slave ObjectCode 88 src Figure 5 LINkits CodeWarrior Project Structure LINkits LIN Evaluation Boards Rev 2 10 Freescale Semiconductor References 7 References AN2503 D Slave LIN Driver for MC68HC08Q Family LIN Protocol Specification Version 1 3 12 December 2002 LIN Driver User s Manual 9812C32DGV I D MC68HC9812C32 Device Guide MC68HC908GZ60 D MC68HC908GZ60 Technical Data MC68HC908GR60 D MC68HC908GR60 Technical Data MC68HC908EY16 D MC68HC908EYI6 Technical Data MC68HC908QY4A4 D MC68HC908QY4 Technical Data 8 MC68HC98S12C32 Master Software Listings BORK k k k k k k k k k k k k k k k k k k k k k K a k K Sk RK K K KOR K K ke ke e K K KOR R K K Sk Sk R K a a a K K K a a K a a a R ke ke R R K KKK k k Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample master master c v Author SAuthor snl Locker SLocker 5 State State Exp Revision Revision 1 2 5 Functions Sample application for S12 LINKits Master Driver History Use the RCS command log to display rev
13. has an on chip clock and thus does not require an external crystal It has an additional jumper J3 to isolate because it is required to be high for monitor mode entry This jumper should be fitted for normal use and removed only when entering monitor mode The GZ60 master board is similar to the GR60 slave but GZ60 includes an MC33388 CAN interface The master boards also have a co axial socket to allow the connection of the 12 V power supply included in the accessory kit This is primarily intended for use with the demonstration application because all the LIN kits boards have two 4 pin 8 amp Molex connectors LIN 12 volts and 2 grounds These are intended for daisy chaining multiple slaves but can also be used to supply power The 9S12C32 master board is similar to the GZ60 but the MONOS interfaces of the 9812C32 are replaced by a 6 pin background debug mode BDM connector As a possible low cost alternative to the use of the 1 To achieve this current the LED attached to the 12 V line should be removed from the board LINkits LIN Evaluation Boards Rev 2 4 Freescale Semiconductor Master Software BDM interface the 9512 PCB includes an RS 232 interface This will however only be convenient to use if the MCU fitted is an 9512064 which has a second SCI rather than an 9812C32 All the HC08 PCBs have two debug interfaces which allow engineering use of the boards in monitor mode These are the 16 pin Cyclone Mul
14. k k k k k k k k k k k a a k k k K K k K Sk ke KK K K KOR K K K R R K K a a kk Sk kk KOR R K K R R R K R RR ke R R K RO ke eek NODE STARTUP By default compiler startup routine is called User is able to replace this by any other routine HR k k k k k k k k k k k k k k k k k k k k K K KOK K k K KOK K K KOK K K k KOR K K KOR R K k KOR K K KOR R K KOR R R R KOR R R KOR R k k OR R RK k R R K 7 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 31 Amz SEA HCO8EY16 h Register Definitions for the MC68HC908EY16 Hif defined define Node Startup Startup extern void Startup CWO8 compiler startup routine declaration endif defined Cwos dif defined COSMICO8 define Node Startup _stext extern void _stext Cosmic compiler startup routine declaration endif defined COSMICO8 BRK RR RRR KK RR RR RR RRR a a a RK RK KR Sk Sk Sk RR a a RRR RK RR a a a k a a a k a a a a RRR RR RR RK KK RK INTERRUPT VECTORS TABLE User is able to add another ISR into this table instead NULL pointer k k k k a a a a a a a a k k a a a a a k k a a KR KOK k K KOK K K k KOR K K KOR R K a KOR K K R R RR R R KOR R R R R R RR k k R KR R R Hif defined NULL define NULL 0 endif defined NULL undef LIN VECTF if defined CW08 define LIN VECTF void const pragma CONST SEG VECTORS DATA vectors segment declaration void const vectab endif defined CWO8
15. k k k k k k k k k k k k k k Sk ke k k k OK K k k KOK K K ke K K K KOR K K Sk Sk ke e K KOR K k k R R K RO R R R R KOR R R KOR R R k ke ke R ke k k R K x define LIN MSG 17 LIN SEND EY16 Slave IDs define LIN MSG 21 LIN RECEIVE define LIN MSG 22 LIN RECEIVE define LIN MSG 23 LIN RECEIVE define LIN MSG 20 LIN RECEIVE GR60 Slave IDs define LIN MSG 29 LIN RECEIVE define LIN MSG 2A LIN RECEIVE define LIN MSG 2B LIN RECEIVE define LIN MSG 28 LIN RECEIVE QY4 Slave IDs define LIN MSG 19 LIN RECEIVE define LIN MSG 1A LIN RECEIVE define LIN MSG 1B LIN RECEIVE define LIN MSG 18 LIN RECEIVE Reserved Slave IDs define LIN MSG 11 LIN RECEIVE define LIN MSG 12 LIN RECEIVE define LIN MSG 13 LIN RECEIVE define LIN 10 LIN RECEIVE define LIN MSG 17 LEN 2 standard length 1 LIN MSG 21 LEN 2 LINkits LIN Evaluation Boards Rev 2 18 Freescale Semiconductor MC68HC9S12C32 Master Software Listings define LIN MSG 22 LEN 2 define LIN MSG 23 LEN define LIN MSG 20 LEN N N define LIN MSG 29 LEN define LIN MSG 2A LEN define LIN MSG 2B LEN define LIN MSG 28 LEN N N N N define LIN MSG 19 LEN define LIN MSG 1A LEN define LIN MSG 1B LEN define LIN MSG 18 LEN N N N N define LIN MSG 11 LEN define LIN MSG 12 LEN define LIN MSG 13 LEN 1 LIN MSG 10 LEN N N N N endif d
16. 00 Enable interrupt if defined CW12 asm cli endif defined CW12 Hif defined COSMIC12 asm cli endif defined COSMIC12 Check Enable LIN interface LINActive Test message for comms debug MsgSent 0 0x55 MsgSent 1 OxAA Update message ret LIN PutMsg 0x17 MsgSent Send a request for message ret LIN RequestMsg 0x17 Wait for message processing do while ret a LIN STATUS PENDING ret LIN DriverStatus Check sent message status ret LIN MsgStatus 0x17 if ret LIN LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 15 BEE sI m sa uCWVII MC68HC9S12C32 Master Software Listings ErrCount 1 while 1 Schedule Loop while 1 Check Enable LIN interface LINActive Slave received messages cycle here for i 0 i lt messageList 1 Send a request for message ret LIN RequestMsg idList i Wait for message processing do while ret amp LIN STATUS PENDING ret LIN DriverStatus Check received message status ret LIN MsgStatus idList i if ret LIN OK Read message ret LIN GetMsg idList i MsgRcvd Was message found last time if activeList i 0 so new Id was added activeList i 1 Flash LEDs to indicate ne
17. 1 if TBCR 0x80 is TBM flag set TBCR 0x08 yes clear it LIN IdleClock check for LIN activity if LIN DriverStatus bus idle for 375 trys PTB amp 0x20 yes power down MCU count used for LED flashing PTB 0x10 toggle tick output Read_button read button on PTA4 LED display update LEDs on PTBO 3 LIN response send LIN response msg LINkits LIN Evaluation Boards Rev 2 24 Freescale Semiconductor s Su MC68HC908EY16 Slave Software Listings BRR RRR RK RR a RR RK KR RK a ke e RK KK a kk Sk Sk KR RK a a a a a a a a a a a kk kk RR RK RRR e a ke ke RK KK k k k Function name Originator Date Function void Read button vo unsigned char key key amp 0x10 read button on A4 if key key last same as last time if keycount debounce yes debounce 2 th if key 0 yes key pressed if mode yes ID mode ID yes increment ID if ID 4 ID 0 wrap round from 3 to 0 else no normal mode data increment data if data 16 data 1 wrapping from 15 to 1 keycount prevents re entry else if keycount lt modecount prevents wraparound keycount if keycount modecount time for modechange if key 0 yes key pressed mode
18. 7 MB IOIOhEOS osse be RU EET key kode 11 8 gt MC68HC98S12C32 Master Software Listings 11 Appendix AMaster hi usi obe br esiri irrin 17 Appendix BMaster id L vw u a e rr Rene 18 Appendix CMaster elg l 19 Appendix cs ses er ch Rr ER REG ns 20 9 MC68HC9OBEY16 Slave Software Listings 23 10 HCO8EY16 h Register Definitions for the MC68HC908EY16 27 Appendix ESlave id LIN Message ID File 29 Appendix FSlave cfg LIN Configuration File 29 Appendix G define _ 31 2 freescale semiconductor LINkits Demonstration Application 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 it
19. EAR TBM FLAG CHECK LIN BUS STATUS Y YES INACTIVE FOR 5 NO Y INCREMENT COUNT TOGGLE TICK Y TAKE APPROPRIATE ACTION FIGURE 4 READ PUSH BUTTON SWITCH AND o MESSAGE WITH SELECTED ID Y NO ID MODE WRITE DATA TO LEDS 9 YES Y lt COUNT BIT 4 HIGH NO A YES y WRITE D TO LEDS y ADD RESPOND FIELD TO THE LIN ALL LEDS OFF Figure 3 MC68HC908EY16 Slave Software Main Flow Chart LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor Slave Software READ PUSH BUTTON SAME NO RESET COUNTER AND SAVE BUTTON STATUS YES Y DEBOUNCED NO lt lt MODECOUNT NO YES YES y PUSH BUTTON PRESSED N NO 9 YES Y NO lt a ID MODE 2 Y yon INCREMENT DATA INCREMENT ID Y Y NO NO DATA 16 ID 4 gt g YES YES DATA 1 ID z0 INCREMENT KEYCOUNT COUNTER lt Y NO MODECOUNT gt i YES Y PUSH BUTTON PRESSED N NO gt BACK TO NORMAL MODE YES ID CONFIGURATION MODE Y Figure 4 MC68HC908EY16 Slave Software Push Button Flow Chart The function LED display writes the required data to the four I O lines con
20. Freescale Semiconductor Application Note Document Number AN2573 Rev 2 01 2007 LINkits LIN Evaluation Boards by Peter Topping East Kilbride 1 Introduction This application note describes the demonstration application that is programmed into the LINkits evaluation boards The LINkits boards comprise two LIN masters MC68HC9S 12C32 D64 MC68HC908GZ60 and four slaves MC68HC908GR60 MC68HC908EY 16 MC68HC908QY4 and MC68HC908QLA These devices will be referred to as the 9812C32 9512064 GZ60 GR60 EY 16 QY4 and 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 Freescale Semiconductor Inc 2006 All rights reserved Contents 1 Introdlucll H xii crac 1 2 LINkits Demonstration Application 2 B Badius seq kon den ee T a ee dede vf ws 3 4 Master 5 D Slave SOWA wan aa seta aaa pa ka Oe Rd 7 6 CodeWarrior Project ors koka kaa kaa ane kak nyeri Aaa 10
21. NST SEG VECTORS DATA endif defined CW12 dif defined CW12 void near const near vectab endif defined CW12 1 defined COSMIC12 void near const near vectab endif defined COSMIC12 BORK KR RK RK KK kkk k k k Sk k k k k k k a a a k k k k KK a k k k k k k k RR k kk k k kkk kk kkk RK RR ke ke RK KK C32 BORK RR RRR KR k k k k k k k k k k k k k k k a a a k k k k KK a a k k a a k k k a a a a a a a k k a a a kk a a RRR a a a e ke ke ke ke kx if defined C32 LIN VECTF NULL OxFF80 Reserved LIN VECTF NULL OxFF82 Reserved LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 21 MC68HC9S12C32 Master Software Listings N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF N VECTF by ty IET ES ES EYuESCET Et ECC ESSET ET ba ki pra pipa ET ETOEY tota ki ELEV EE EE ET O ty EE pria EE ESSETJET EYES dif LIN VECTF NULL NULL NULL NULL NULL NULL NULL NULL NULL
22. NULL NULL NULL NULL NULL NULL LIN ISR SCI Interrupt NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL fined MASTER LIN ISR Timer0 endif defined MASTER dif defined SLAVE OxFF84 OxFF86 OxFF88 OxFF8A OxFF8C OxFF90 OxFF92 OxFF94 OxFF96 OxFF98 OxFF9A OxFF9C OxFF9E OxFFAO OxFFA2 OxFFAA OxFFA6 OxFFAS8 OxFFAA OxFFAC OxFFAE OxFFBO OxFFB2 OxFFB4 OxFFB6 OxFFC2 OxFFC4 OxFFC6 OxFFDO OxFFD2 OxFFD4 OxFFD6 OxFFD8 OxFFDA OxFFDC OxFFDE OxFFEO OxFFE2 4 OxFFE6 OxFFES8 OxFFEA OxFFEC OxFFEE Reserved Reserved Reserved Reserved PWM Emergency Shutdown Port P MSCAN 4 transmit MSCAN 4 receive MSCAN 4 errors MSCAN 4 wake up MSCAN 3 transmit MSCAN 3 receive MSCAN 3 errors MSCAN 3 wake up MSCAN 2 transmit MSCAN 2 receive MSCAN 2 errors MSCAN 2 wake up MSCAN 1 transmit MSCAN 1 receive MSCAN 1 errors MSCAN 1 wake up MSCAN 0 transmit MSCAN 0 receive MSCAN 0 errors MSCAN 0 wake up FLASH EEPROM SPI 2 SPI 1 IIC Bus DLC SCME CRG lock
23. VE The following numbers assume that the ESCI prescaller 1 Selects 9600 baud rate if using a 4 9152MHz crystal define LIN BAUDRATE 0x03u Selects 9600 baud rate if using an 8 000MHz crystal define LIN BAUDRATE 0x30u Selects 9600 baud rate if using a 16 000MHz crystal LINkits LIN Evaluation Boards Rev 2 7 x y Filename SRCSfile net sdt vault rte cvsroot lin release hc08 sample master master cfg v 5 Author SAuthor kam 5 Locker SLocker State State Exp Revision Revision 1 12 Functions LIN Driver static configuration file for LINO8 LINkitsMaster sample History Use the RCS command log to display revision history information KR KKK k k k k k k k k k k k k k k k ke k k k K k k k KOK k K ke K K K KOR K K KOR R RR KOR R k R R R R R KOR R R KOR OR R k k ke ke ke k k R K x 30 Freescale Semiconductor HCO8EY16 h Register Definitions for the MC68HC908EY16 define LIN BAUDRATE 0x31u Selects 9600 baud rate if using a 32 000MHz crystal define LIN BAUDRATE 0x32u This definition sets the number of user defined time clocks LIN IdleClock service calls recognized as no bus activity condition This number shall not be greater than OxFFFF define LIN IDLETIMEOUT 375u endif define LINCFG H vector c Appendix G define VECTOR C BRK k k k k k k k k k k k k k k k k e a a k a a Sk k a ke K e a
24. a a K KOR Sk K a ke e K K a a a K K a a a K KOR a KOK R KOR K k a a K a KOR R K KKK k k Copyright C 2003 Motorola Inc All Rights Reserved Filename RCSfile Zuk07 i102 8 16BitMCU Strategic 040Mktg Sys RCS D Projects CW LINO8EY16_ src hc08 vector c v Author SAuthor ttz778 5 Locker SLocker 5 State State Exp Revision Revision 1 0 Functions Vectors table for LINOSEY16 Drivers History Use the RCS command log to display revision history information The users can add their own vectors into the table but they should not replace LIN Drivers vectors Notes 1 The only one of the following variables may be defined while all others are undefined This is controlled by the compiler option which in turn is to be adjusted in makefile or batch file HCO8EY16 Description Vector table and node s startup for HCO08 HR k k k k k k k k k k k k k k k k k kk k k a a K k R R R R R R R KOR R R R ke ke ke ke k k R K x 1 defined HCO8EY16 extern void LIN ISR SCI Receive ESCI receive ISR extern void LIN ISR SCI Error ESCI error ISR extern void TimerA0 Timer Module A Channel 0 ISR extern void TimerA1 Timer Module A Channel 1 ISR extern void TimerB Timer Module B Overflow ISR extern void BREAK Command SWI ISR endif defined HCO8EY16 BRK k k k k k
25. ale Semiconductor Japan Ltd Headquarters ARCO Tower 15F 1 8 1 Shimo Meguro Meguro ku Tokyo 153 0064 Japan 0120 191014 or 81 3 5437 9125 support japan freescale com Asia Pacific Freescale Semiconductor Hong Kong Ltd Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po N T Hong Kong 800 2666 8080 support asia freescale com For Literature Requests Only Freescale Semiconductor Literature Distribution Center P O Box 5405 Denver Colorado 80217 1 800 441 2447 or 303 675 2140 Fax 303 675 2150 LDCForFreescaleSemiconductor hibbertgroup com Document Number AN2573 Rev 2 01 2007 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document Freescale Semiconductor reserves the right to make changes without further notice to any products herein Freescale Semiconductor makes no warranty representation or guarantee regarding the suitability of its products for any particular purpose nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability including without limitation consequential or incidental damages Typical parameters tha
26. e IDs are however not supported by the programmed demonstration application 3 Hardware Figure 1 shows the main circuit diagram of the MC68HC908EY 16 LINkits slave board This constitutes the complete LIN node and also shows the function of the three jumpers on the board These jumpers are only required when using the board to program or debug application software and should not be inserted when running the demonstration program a fourth jumper J3 only on the QY4 slave should be inserted when running the demonstration program When in the debug mode additional hardware is required to connect the LINkits board to the PC containing the development environment For clarity these interfaces are not shown in Figure 1 The complete circuit diagram also shows the two 20 way connectors P1 and P2 These allow access to all of the MCU s pins and facilitate the addition of a top board incorporating user application hardware Given the different resources and pin outs of the various devices the pin outs of PI 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 physical interface used is the MC33399 or MC33661 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 3 Hardware and the
27. e IOBYTE address define IOWORD address Registers undefined in standard LIN drivers define PTA 0 0000 define PTB IOBYTE 0x0001 define PTC IOBYTE 0x0002 define PTD IOBYTE 0x0003 define PTE 0x0008 define DDRA IOBYTE 0x0004 define DDRB 0x0005 define DDRC IOBYTE 0x0006 define DDRD 0x0007 define DDRE 0x000A define SCBR IOBYTE 0x0016 define SCPSC IOBYTE 0x0017 define CONFIG1 0 001 define CONFIG2 0 001 define TBCR IOBYTE 0x001C define TASC 0x0020 define TACNTH 0 0021 define TACNTL 0 0022 define TAMODH 0 0023 define TAMODL 0x0024 define TASCO 0 0025 define TACHOH 0 0026 define TACHOL 0x0027 define TASC1 0 0028 define TACH1H 0 0029 define TACH1L 0x002A define TBSC 0x002B define TBCNTH 0x002C define TBCNTL 0x002D define TBMODH 0x002E define TBMODL IOBYTE 0x002F define TBSCO 0 0030 define TBCHOH 0 0031 define TBCHOL 0 0032 define TBSC1 0x0033 define TBCH1H 0 0034 define TBCHIL 0 0035 define ICGCR define ICGMR
28. efined LINMSGID H Appendix C Master cfg ifndef LINCFG H define LINCFG H BRK k k k k e k k k k k k k k k k k e a k a a a k K Sk a ke e e a a a K a a K K KOR e K K a a a K K KOR OR RR K k a a K K KOR R ke ke R a K R OR K K Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile net sdt vault rte cvsroot lin release hc12star sample master master cfg v Author SAuthor kam Locker SLocker State State Exp Revision Revision 1 4 Functions LIN Driver static configuration file for LINS12 LINKits Master sample History Use the RCS command log to display revision history information Description Example file that can be modified by the user Notes ke k k k k k k k k k k k k k k k k k k Sk ke k e k K K k k KOK K K KOK K K K KOR K K Sk Sk OR K K KOR K K KO RO R R R R R R R R R R KOR R R k k ke R ke k k R K K 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 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 19 MC68HC9S12C32 Master Software Listings This number shall not be greater than OxFFFF define LIN IDLETIMEOUT 100u This definition configures the LIN bus baud rate This value shall be set according to target MCU SCI register usage MC9S12DP256
29. ename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample slave slave c v Author SAuthor snl Locker SLocker 5 State State Exp Revision Revision 1 2 5 Functions Sample application for LINO8EY16 LINKits Slave Driver History Use the RCS command log to display revision history information Function Slave supplies a 2 byte response with a selectable ID The data in the lower nibble of the first byte is the hexadecimal number displayed on the 4 LEDs This number can be incremented using the button on port A bit 4 The default ID is 29 with 2A 2B amp 28 selectable using an ID comfiguration mode This mode is entered by holding the button down for 3 seconds After this the LEDs flash and display the ID 0 29 1 2A 2 2B 3 28 Pressing the button in this mode increments the ID After three seconds of no activity on the button the mode returns to normal ke k k k k k k k k k k k k k k k k k k ke ke k k KOK K k R R R RO R R R KOR R R k ke ke R ke k k R K K pragma DATA SEG SHORT DATA ZEROPAGE BR k k k k e k k k k k k k k k k e e k k k K a k k Sk ke ke e e a KOK K KOR K K KOR R K K a a R R K KOR R K KOR R K K R R R K kk R ke ke ke R K KK eek Includes defines globals and function prototypes HR k k k k k k k k k k k k k k k Sk k k k k k k a a K k Sk ke ke K k KOR K k k KOR K K KOR R K K KOR K K KOR R K KOR R R
30. f their respective owners Freescale Semiconductor Inc 2006 All rights reserved RoHS compliant and or Pb free versions of Freescale products have the functionality and electrical characteristics as their non RoHS compliant and or non Pb free counterparts For further information see http www freescale com or contact your Freescale sales representative For information on Freescale s Environmental Products program go to http www freescale com epp lt gt 77 semiconductor
31. here to give 1ms timeouts KR k k k k k k k k k k k k k k k k k k k k k k a K k k KOK k KR KOR K K KOR R K R a a K K R R R K R R R R R R R R R KOR R k k k ke R ke k k R K x void Delay unsigned int n unsigned int stopTime stopTime Time n while stopTime Time BRR RR KR RK ke e RR RR KR Sk kk ke KR KR KR RR k k ce ake k k ke eoe e ke ke ke ke ke KKK Function NewNode Description Flash LEDs in sequence low to high Returns none Notes ROK a k k k k k k k k k k k k k k k k k e k k k k K K k k KOK k K k KOR K K OR K K k KOR K K KOR R K K OR R k a a R R R OR R K R R R ke ke ke R R K K k void NewNode char i unsigned char strip 0x01 for i 0 i lt 8 i PORTB strip Delay 125 strip strip 1 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 13 lt v SYIE sI m MC68HC9S12C32 Master Software Listings BRR RR KR KR RR RR a a KR RR KR RR a a KR a a a a a a a a a a a a RR RR RRR RK RRR KK RK Function LostNode Description Flash LEDs in sequence high to low Returns none Notes RK KK k k k k k k k k k k k k k k k k k k k k KOK K k a ke ke K k KOR K K KOR K K R R R K K K R R K K KOR R k KOR R R R R R R K R R R ke ke ke R R K k k void LostNode char i unsigned char strip 0x80 for i 0 i lt 8 i PORTB strip Delay 125 strip
32. id if mode if count 0x08 else PTB PTB amp OxFO 1 lt lt ID ID mode LED display PTB amp OXFO ID mode flash LEDs off else normal mode so amp OxFO data amp OxOF drive LEDs with data BRR RR RRR ke e KK RK ck Sk Sk Sk ke a a RK RR RR RK RRR e a a ke ke a a ke RK Function name LIN response Originator P Topping Date 19th June 2003 5 Function According to ID 0 21 1 22 2 23 3 20 a 2 byte response field is sent using data for the lower nibble of the first byte All the other bits are zero HR KKK RK RK KR k k k k k k ck K k K ke e K K KOK OK K K KOR K K KOR R K k KOR K k KOR R K KOR R R R KOR R k e R ke k k k R e R R R K 7 void LIN_response void LIN data 0 data LIN data 1 0 switch ID 0 LINkits LIN Evaluation Boards Rev 2 26 Freescale Semiconductor HCO8EY16 h Register Definitions for the MC68HC908EY16 LIN PutMsg 0x21 LIN data LIN response to ID21 break case 1 LIN PutMsg 0x22 LIN data LIN response to ID22 break case 2 LIN PutMsg 0x23 LIN data LIN response to ID23 break case 3 LIN PutMsg 0x20 LIN data LIN response to ID20 break BOR RK KK KK KK RR RR KR RK KR KR RR RR a a a a Sk Sk ke KR RR k Function LIN_Command Description User call back Called by
33. ified by the application code To avoid compromising the timing of LIN communications no interrupts other than those from the LIN drivers themselves are allowed Within these limitations channel 2 of the timer is available for use by the application 6 CodeWarrior Project The demonstration project is structured as shown in lt st blue gt lt st bold gt Figure 5 The folder sample contains the demonstration application code that is programmed into the LINkits evaluation boards This is where any application being developed with the evaluation boards should reside The other folders contain the LIN driver code which should not normally be modified by the user Its source code include files and user manual reside in the src inc and man folders respectively The vector definition file vectorc is in the hc08 folder The sample directory contains the application source code slave c and two additional files that determine the behavior of the slave node The first is slave cfg which specifies the SCI prescaler value appropriate for the frequency being used and the number that determines the 5 second no bus activity timeout The second is s ave 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 lt st blue gt lt st bold gt References The sample directory also contains the projects prm mcp and ini files and an include file slave h for register definitions not already
34. ision history information Description Communicates with 16 LIN nodes and displays their data Notes Also serves as an example of use for the LIN driver HR RK KR KR KK RK k k k a k k a a K k K KOK K K KOK K K k KOR K K KOR OR R ke R R R K K include lt linapi h gt include master h unsigned char ErrCount errors counter unsigned char MsgCount messages counter unsigned char MsgSent 2 transmited data unsigned char MsgRcvd 4 received deta unsigned int Time time from real time counter ROR KKK a a RK RR RK RR KK RR KKK KK a a a a RK RR RK a a a a a a a a a a RR RR RK ke ke k k k a al Function LIN_Command Description User call back Called by the driver after successful transmission or receiving LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 11 Pe ANLLLLLLLLLLLLNEZUNI MC68HC9S12C32 Master Software Listings of the Master Request Command Frame ID Field value 0x3C Returns never return Notes KR RK k k k k k k k k k k k k k k k kk k k k K K k k KOK k K KOK a K K KOR K K KOR R K K a a K k R R R K k k R ke R R R R KOR R R k k ke R ke k k R K x void LIN while 1 BRR RR RRR KK RR KR RR RRR KR RK RRR KK RR ROKR Sk k ke e k RR RRR RR RK RK ke eee ke ke ke ke ke KKK Function Delay Description Initialise RTI for use in Delay function Returns none Notes
35. isted 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 s main function continually cycles round the 16 IDs used in the demonstration application see Table 1 This is done using the array idList 16 which is initialized to contain all the defined IDs If LIN MsgStatus indicates that there is a response for a particular ID its data is read and its byte in the array activeList 16 is checked to see if this is a new node it wasn t previously present If so its byte is set to a 1 and NewNode is executed to perform the LED display which indicates that a node has been added If there is no response to a particular ID activeList 16 is checked to determine whether there was a response to that ID the previous time around the loop If there was a response the previous time the node has since been removed This is indicated on the LEDs using LostNode NewNode and LostNode are also used to provide the continuous sweeping LED display when the LIN master is not active This is determined in the function LINActive which reads the slide switch on the master PCB LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 5 Master Software YES Y INITIALIZE PORTS AND LIN DRIVERS ENABLE INTERRUPTS
36. l to ID configuration or ID configuration to normal is required If the state of the button pressed or not pressed is different from what it was the previous time through the loop the counter is reset and the state remembered in key last If however the state of the button is the same the counter value is compared with the required number for a debounce time of about 60 ms If the counter value is equal and the key is pressed the data or ID is incremented according to the current mode If the count is different from that required for debounce it is compared with the mode change requirement If it is less the counter is incremented If it is or has now become equal to the mode change requirement then the mode is changed to ID configuration mode if the key is pressed or to normal mode if it isn t This arrangement ensures that the mode defaults automatically to normal if the key remains not pressed for three seconds the time it takes the counter to reach the mode change number 224 for the EY 16 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 7 Slave Software LIN WAKE UP SWITCHES MCU POWER ON AND LIN DRIVERS ENABLE INTERRUPTS Y INITIALIZE CONFIG PORTS TBM ICG ENTER SLEEP MODE BY PUTTING THE REGULATOR INTO x STANDBY MODE VIA THE MC33399 MCU IS SWITCHED OFF lt a Y TBM FLAG SET NO YES Y CL
37. le IDs ERU oue Alternative IDs GR60 29 2A 2B amp 28 1101 d 1110 1111 8 1100 2C 2D 2E amp 2F EY16 21 22 23 amp 20 1001 d 1010 1011 amp 1000 24 25 26 amp 27 QY4 19 1A 1B 8 18 0101 d 0110 0111 amp 0100 1C 1D 1E amp 1F QL4 11 12 13 amp 10 0001 d 0010 0011 amp 0000 14 15 16 amp 17 The master cycles round the IDs of all the slaves that it finds to be present and displays each slave s ID using the bottom leftmost four LEDs The two leftmost LEDs show the slave type and the next two LEDs show the two LSBs of its ID using the code shown in Table 1 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor Hardware The choice of IDs their display formats and the skipping of zero in the data field ensure that there is at least one 1 in each 4 bit field These provisions eliminate the possibility of an all zero slave display which would also be represented in the master display by no illuminated LEDs The only exception to this is the ID field displayed by the master for the last configurable QL ID 10 Slaves can be added or removed from the bus without powering down or resetting the boards When the master recognizes a new slave it indicates this by sweeping the LED display once from 0 to 7 It then adds this slave to its display sequence When it loses a slave it shows this by sweeping the LEDs from 7 to 0 and removing it from the display sequence
38. nected to the LEDs ensuring that no change is made to any of the other bits on the same port The data sent is the 4 bit variable data or the 2 bit variable D according to the current mode The ID is not displayed in binary so the variable D is used to shift a single 1 to the appropriate position To distinguish the ID display this LED flashes at about 2 Hz using the counter count LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor CodeWarrior Project The function LIN response uses the variable ID so that the appropriate LIN PutMsg ID data is active In order that the others are inactive LIN SEND UPDATED should be specified in file s ave id e g define LIN MSG 20 LIN SEND UPDATED If LIN SEND is used the LIN drivers will always send a response after LIN PutMsg ID data has been executed for that ID This does not apply to the QY4 because it uses the file LINmsg c instead and the type of send can be defined there see user s manual in st blue st bold References The GR60 doesn t have an ICG to initialize but its slave code is otherwise very similar to that of the EY 16 The QY4 has no TBM module so it uses the main timer s overflow flag to pace its loop This MCU also doesn t have an SCI its LIN interface is implemented using I O pins in conjunction with the timer s channel 1 input capture and output compare interrupts For this reason the QY4 s timer counter and modulus registers should not be mod
39. odule it uses the main timer s overflow feature instead Because of the different clocks used by each board the frequency of code execution in the loop is different for each slave type defines are used to determine the two periods required for correct execution of the program push button debounce time about 60 ms and mode change time 3 s A third critical time go to sleep in five seconds if there is no LIN activity is defined in slave cfg GR60 and EY 16 only This feature uses the LIN functions LIN_IdleClock and LIN driverStatus as described in the LIN driver manual see Section 7 References After the predetermined number of executions of LIN IdleClock with no LIN activity LIN driverStatus ceases to return LIN OK 0x01 and the MC33399 is shut down by lowering its enable line This switches off the 5 V regulator and the MCU powers down If LIN messages are present the remaining code in the loop is executed This increments count toggles a port line for debug use to check the loop execution rate reads the push button switch using Read button updates the LEDs using LED display and supplies the relevant response data using LIN response The flow chart for the function Read button 15 shown in Figure 4 The counter keycount is used to determine whether the push button has been in a particular state for long enough for action to be taken It is used both for debounce and to determine whether a mode change norma
40. regulator is an LT1121 though these two chips can be replaced by a single chip the MC33689 LIN SBC systems base chip The MCU enables the MC33399 which controls the regulator When there is no LIN activity the MC33399 shuts down the regulator thus powering down the MCU and putting the node to sleep with an Ipp of less than 50 ul This can be seen by the LEDs switching off because the demonstration software is written in such a way that at least one LED is always on when the MCU is powered up An absence of LIN bus activity will not cause MC68HC908QY4 to go to sleep Vl VS im 5V s 3 ale 100 kO 2 2kQ 1k e td NAN Jo MONITOR MODE x lus IRQ 27 5 V DEBUG PUSH BUTTON St 7 8 47 ZENER Vs INA TA 6 2 9 18 YT LIN EN B5 MC68HC908EY16 Bo m MC33399 24 e B2 12 23 ESCI B3 3 WAKE Ts o GND 5 OSCILLATOR MODULE Vss NN yy DEBUG 6 osct Mesi ye I 3 KA 25 GND id o o o o Figure 1 MC68HC908EY16 LINkits Slave The other slaves are very similar to the EY 16 The 48 pin GR60 is intended for use in high end LIN nodes It does not have an on chip clock generator and thus the PCB incorporates a crystal and its associated passive components The QY4 is aimed at low end nodes and like the EY 16
41. s 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 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 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 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 2 LINkits Demonstration Application The master has two modes selected by its slide switch In one mode a single lit LED sweeps up and down the display indicating that no LIN header frames are being sent In this mode any slaves connected should be in sleep mode With the switch in the other position the master sends headers for all the IDs used in the demonstration application and checks to see which are actually present If a slave is present the identification code and data is displayed in turn for all the IDs for which a response is received The IDs used are shown in Table 1 Table 1 The LIN IDs Used by Each Type of Slave Slave Default ID Configurab
42. s into the table but they should not replace LIN Drivers vectors Notes Timer Channel 0 vector used for Master driver only The following variables shall be defined this is controlled by the compiler option which in turn is to be adjusted in makefile or batch file C32 MASTER or SLAVE k k k k k k k k k k k k k k k k k k k k k k k OK K k K KOK k K KOK R k k KOR K K KOR R K k KOR K K KOR R K R R R R R KOR R k R R R RR k k R K k k R K K extern void LIN ISR SCI Interrupt SCI interrupt routine extern void LIN ISR Timer0 Timer channel 0 interrupt routine extern void LIN Startup LIN Startup routine extern void RTI ISR LIN Startup routine BORK KR KR KKK KR a a a KR RK Sk Sk ke KR ck ck Sk Sk RK a a a a Sk Sk ke a a k a k e a ke ke KK ke k k k k INTERRUPT VECTORS TABLE User is able to add another ISR into this table instead NULL pointer HR k k k a a k k k k k k k k k k k k k k k k k k a K k Sk ke k K KOK K K k KOR K K KOR R K K KOR K R R K KOR R R R R R R k R R R ke k KOR R KOR R R if defined NULL define NULL 0 endif defined NULL undef LIN VECTF dif defined CW12 define LIN VECTF void const near Vector table function specifier endif defined CW12 1 defined COSMIC12 define LIN VECTF void const Vector table function specifier endif defined COSMIC12 1 defined CW12 pragma CO
43. strip gt gt 1 BOR KR KR RK a a RK KK KK a a a RR RR RRR RR RR RRR RR RR RRR k k e ke RR RK KKK Function LINActive Description Returns only if master switch has enabled LIN Returns none Notes Flashes LEDs if LIN is disabled RK KK k k k k k k k k k k k k k k k k k k k a a a RR KR a a K KOR K K RR RRR R k KOR R R RRR ke R ke KOR R R K R x void LINActive Check switch position PERJ 0x40 while PTJ amp 0x40 0 NewNode LostNode Enable LIN interface PERJ 0x80 BOR RR KR KKK RR RR RR RR RRR e e KK RRR KR RRR RRR RR RRR RR RK RRR e ke ke ke ke ke ke KK Function main Description Sends and receives 2 bytes messages periodically Returns never return Notes LINkits LIN Evaluation Boards Rev 2 14 Freescale Semiconductor MC68HC9S12C32 Master Software Listings KR k k k k k k k k k k k k Sk a ke k k k a K k Sk Sk k kk k K K KOR K K KOR R K K KOR K K KOR R K KOR R R R KOR R R KOR OR R k k ke R ke k k R ex void main void int i nodeId unsigned char statusDisplay LINStatusType ret unsigned char idList 16 0 10 0x11 0x12 0x13 0x18 0x19 Ox1A Ox1B 0x20 0x21 0x22 0x23 0x28 0x29 0x2A 0x2B char activeList 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 char messageList 16 Time 0 Initialize driver LIN Init Enable LED display PORTB OxFF DDRB OxFF Initialise RTI InitDelay 160
44. t may be provided in Freescale Semiconductor data sheets and or specifications can and do vary in different applications and actual performance may vary over time All operating parameters including Typicals must be validated for each customer application by customer s technical experts Freescale Semiconductor does not convey any license under its patent rights nor the rights of others Freescale Semiconductor products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application Buyer shall indemnify and hold Freescale Semiconductor and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expenses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc All other product or service names are the property o
45. the 16 bit value is masked by Ox1FFF and put into SCIOBD register define LIN BAUDRATE 52u This definition configures the timer clock rate Only for Master node This value shall be set according to target MCU timer prescaler register usage MC9S12DP256 the 8 bit value is masked by 0x07 and put into TSCR2 register Fi define LIN TIMERPRESCALER 3u This definition set the length of one bit transmission period on the target MCU Only for Master node Due to 16 bit counters on target MCU this value shall not be greater than OxFFFF For correct timeouts computation this value Shall have qualificator l define LIN BITTIME 104ul endif define LINCFG_H Appendix D Vector c define VECTOR_C BRK KK a a RR RRR KR RR KR KR a a KR RK a a RRR KR RR RRR RR a a RRR RR a a KK KK k k k Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile vector c v Author SAuthor ttz778 5 Locker SLocker ttz778 5 State State Exp Revision Revision 1 0 Functions Vectors table for LINS12 Drivers with Motorola API History Use the RCS command log to display revision history information Description This file contains vectors tables for MC9S12DP256 MCU LINkits LIN Evaluation Boards Rev 2 20 Freescale Semiconductor MC68HC9S12C32 Master Software Listings It used for LIN Drivers with Motorola API The users can add their own vector
46. the driver after transmission or reception of the Master Request Command Frame ID 0x3C RR k k k k k k k k k k k k k k k k k k k k k k k K k k K KOK k K KOK K K K K Sk K K KOR R K R KOR K R KOR R K R R R R R KOR R k ke R ke k k k R ee k kk k void LIN Command while 1 10 HCO8EY16 h Register Definitions for the MC68HC908EY16 BORK k k k k k k k k k k k k k k k k k a k k k Sk k Sk ke k a R K K KOR OK K Sk ke e K K KOR R K K KOR R K KOR R K K ke k k k R ke ke R R KOR RO RK Copyright C 2003 Motorola Inc All Rights Reserved xk X Filename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample master master c v Author SAuthor snl 5 Locker SLocker 5 State State Exp Revision SRevision 1 2 Functions Sample application for O8EY16 LINKits Slave Driver History Use the RCS command log to display revision history information Description Header file for slave c Notes Also serves as an example of use for the LIN driver HR k k k k 1k k k k k k k k k k k k k k k a k k k K K k K KOR k K KOK K K k KOR RR KOR K K KOR R K R R R R R KOR R k e ke ke k KOR R e k R R 7 LINkits LIN Evaluation Boards Rev 2 Freescale Semiconductor 27 HCO8EY16 h Register Definitions for the MC68HC908EY16 void Read button void void LED display void void LIN response void void LIN Command void void Dummy ISR void defin
47. tiLink interface and an RS 232 connection directly to the PC via a 9 pin D connector The RS 232 connection uses a level translator and an oscillator module These are powered up using the appropriate jumper J3 for the EY16 board This jumper also supplies a pullup on the enable line to the MC33399 to prevent a power down when the reset button is pressed in the absence of LIN activity With no LIN activity the node would normally be powered down but this jumper prevents this from happening in debug mode This debug jumper should also be inserted when using the Cyclone MultiLink interface Although this supply may not be required applying 5 V to the RS 232 interface chip prevents contention on PTAO I O line The inclusion of the jumper also ensures that the oscillator module which can optionally be used in this mode is powered up When using the RS 232 MONOS interface 9 V is required on the IRQ pin in order to enter monitor mode To achieve this the appropriate jumper J2 on the EY 16 board should be fitted This mode also requires a clock source and an additional jumper J4 on the EY16 board should be used to connect the oscillator module to OSC1 pin This jumper is also required when using the Cyclone MultiLink interface with an external clock selected Cyclone and MultiLink are registered trademarks of P amp E Microcomputer Systems Inc 4 Master Software The flow chart of the master code is shown in Figure 2 The code itself is l
48. w node NewNode MsgCount statusDisplay MsgRcvd 0 amp OxOF i 16 StatusDisplay statusDisplay PORTB statusDisplay Delay 480 else Id not found Was message found last time if activeList i 1 LINkits Evaluation Boards Rev 2 16 Freescale Semiconductor MC68HC9S12C32 Master Software Listings Xes so Id was lost Flash LEDs to indicate lost node LostNode activeList i 0 while 1 main Appendix A Master h BR k k k k k k k k k k k k k k k k KR RRR KK RK RK RRR KR a a KR K K KOR K KR RR RR KOR KK KKK K K Copyright C 2003 Motorola Inc All Rights Reserved Filename SRCSfile net sdt vault rte cvsroot lin release hcl2star sample master master c v Author SAuthor snl Locker SLocker State State Exp Revision Revision 1 2 5 Functions Sample application for 512 LINKits Master Driver History Use the RCS command log to display revision history information Description Header file for master c Notes Also serves as an example of use for the LIN driver KR KK k k ke k k k k k k k k k k k k k k k K K K k K KOK k K a a K Sk a K K KOR OR K R KOR K K KOR R K KOR R R R R R R k R R R ke k KOR e R R R K K void Delay unsigned int n void LostNode void NewNode void RTI ISR void InitDelay unsigned int busfreq

Download Pdf Manuals

image

Related Search

Related Contents

  Instrucciones de servicio superstatic 749  取扱説明書  RAEGuard 2 PID Guía del usuario  Yamaha IMX644 DJ Equipment User Manual  TDS3LIM Limit Test Application Module User Manual - TRS  User`s Guide - Nationwide Security Corporation  TIP BOOK  ILOG Concert Technology 1.1 Migration Guide  Eléments de bibliographie - Les thèses de l`Université Lumière Lyon 2  

Copyright © All rights reserved.
Failed to retrieve file