AN0729 LIN protocol implementation using PICmicro® MCUs

35 145 0
AN0729   LIN protocol implementation using PICmicro® MCUs

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

AN729 LIN Protocol Implementation Using PICmicro® MCUs Authors: ever, instead of having a clock line, each byte is marked via start and stop bits and the individual bits are asynchronously timed like RS232 Dan Butler Thomas Schmidt Thorsten Waclawczyk Microchip Technology Inc ELECTRICAL CONNECTIONS Figure shows a typical LIN Protocol configuration INTRODUCTION LIN Protocol was designed by a consortium of European auto manufacturers as a low cost, short distance, low speed network Designed to communicate changes in switch settings and respond to switch changes, it is intended to communicate events that happen in "human" time (hundreds of milliseconds) This Application Note is not intended to replace or recreate the LIN Protocol Specification Rather, it is intended to provide a broad overview of the bus and provide a high level look at how it works, how to implement a Slave node on a PICmicro® device and what it’s designed to The complete LIN Protocol Specification is expected to be available via the worldwide web at www.lin-subbus.com However, until then, copies of the LIN Protocol Specification may only be distributed by Audi AG, BMW AG, DaimlerChrysler AG, Motorola, Inc., Volcano Communication Technologies AB, Volkswagen AG, and Volvo Car Corporation The bus uses a single wire pulled high through a resistor with open collector drivers A Dominant state is signaled by a ground level on the bus and occurs when any node pulls the bus low A Recessive state is when the bus is at VBAT (9 - 18V) and requires that all nodes let the bus float In the idle state, the bus floats high, pulled up through the resistor The bus operates between 9V and 18V, but parts must survive 40V on the bus Typically, the microcontroller is isolated from the bus levels by a line driver/receiver This allows the microcontrollers to operate at 5V levels, while the bus operates at higher levels The bus is terminated to VBAT at each node The Master is terminated through a 1KΩ resistor, while the Slaves are terminated through a 20-47KΩ resistor Maximum bus length is designed to be 40 meters At press time (early 2000), K-Line drivers are used until true LIN drivers are available BUS FEATURES LIN Protocol supports bi-directional communication on a single wire, while using inexpensive microcontrollers driven by RC oscillators, to avoid the cost of crystals or ceramic resonators Instead of paying the price for accurate hardware, it pays the price in time and software The protocol includes an autobaud step on every message Transfer rates of up to 20Kbaud are supported, along with a low power SLEEP mode, where the bus is shut down to prevent draining the battery, but the bus can be powered up by any node on the bus The bus itself is a cross between I2CTM and RS232 The bus is pulled high via a resistor and each node pulls it low, via an open collector driver like I2C How-  2000 Microchip Technology Inc Preliminary DS00729A-page AN729 FIGURE 1: BUS CONFIGURATION 40m MaxiLIN Protocol 30KΩ nom 1KΩ 30KΩ nom VBAT VBAT 30KΩ nom VBAT VBAT LIN Transceiver LIN Transceiver LIN Transceiver LIN Transceiver Master µC Slave µC Slave µC Slave n DATACRC = COMBUFFER + DATACRC + Carry PORTB,TXLINEPIN BUFFERPTR,W FSR INDF,W COMBUFFER BITLENGTH,W (.39) TMR0 PutDataEnd DUMMY,F PORTB,W (1[...]... FSR,W 0106 3C44 00696 sublw (LINSLAVEBLOCKLENGTH+LINSLAVERAM) 0107 1D03 00697 btfss STATUS,Z ; all done well? 0108 2903 00698 goto ClearLINusedRAM ; no : next loop 00699 0109 1606 00700 bsf PORTB,TXLINEPIN ; Portpin is high on programstart 010A 1683 00701 bsf STATUS,RP0 010B 1406 00702 bsf PORTB,RSLINEPIN ; receive line as input 010C 1206 00703 bcf PORTB,TXLINEPIN ; and transmit line as output 010D 3008... 00681 ; 00682 ; #### init_LinSlave ############################################################ 00683 ; 00684 ; clears all ram locations which are used from the linslave and initializes 00685 ; the portpins and interruptflags 00686 ; 00687 0100 00688 InitLinSlave 0100 3020 00689 movlw LINSLAVERAM 0101 0084 00690 movwf FSR 0102 3024 00691 movlw LINSLAVEBLOCKLENGTH 0103 00692 ClearLINusedRAM 0103 0180 00693... 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 0x20 #define LINSLAVERAM ; startadress ; PB0 connected to the receive line ; PB4 connected to the send line EQU (COPYWREG + 80h) bitposition and bitlength numbers of send/receive block carries the id field bits5 0 carries the ID_number protocols communication errors linbus communication bits ; reserve RAM location on page1 ; checksum over... communication on receive / transmit an outgoing bit value is different than the line value CRC isn’t correct parity over ID not correct #define LINSLAVEBLOCKLENGTH (DUMMY+1 - LINSLAVERAM) #define LINBLOCKEND (DUMMY+1) ;############################################################# ; ; calculate the needed RAM ; space by LINslave MIRRCOPYWREG SYNCLENGTH:0,SYNCLENGTHLO,SYNCLENGTHHI BITREG:0,BITNBR,BITLENGTH... COMBUFFER DATACRC TXDATAFIELD:8 RSDATAFIELD:8 DUMMY:2 ENDC COUNTEDGES COUNTVALUE:0,COUNTVALUELO,COUNTVALUEHI HICOUNT:0,TIMEOUTLO,TIMEOUTHI CBLOCK LINSLAVERAM COPYWREG COPYSTATUS ; RAM location used by LINSLAVE modul 0 4 #define RSLINEPIN #define TXLINEPIN AN729  2000 Microchip Technology Inc  2000 Microchip Technology Inc Preliminary 00000047 00000048 00000049 00000046 00000045 0000003B... preload timer with bitlength correct the timer with MOD 256 -> DATACRC = COMBUFFER + DATACRC + Carry PORTB,TXLINEPIN BUFFERPTR,W FSR INDF,W COMBUFFER BITLENGTH,W (.39) TMR0 PutDataEnd DUMMY,F PORTB,W (1 ... 40m MaxiLIN Protocol 30KΩ nom 1KΩ 30KΩ nom VBAT VBAT 30KΩ nom VBAT VBAT LIN Transceiver LIN Transceiver LIN Transceiver LIN Transceiver Master µC Slave µC Slave µC Slave n

Ngày đăng: 11/01/2016, 11:34

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan