Home
User Manual
Contents
1. We use dlopen to load CANBus library You will see it in the example Like this handle dlopen usr lib libmycanbus so 1 RTLD_NOW Use disym to take a handle of a dynamic library returned by dlopen and the null terminated symbol name returning the address where that symbol is loaded Init_CanBus dlsym handle Init_Can A Call man dlopen to detail information of dlopen disym All functions symbol are listed in next session 4 2 Functions The CanPort library provides the following functions A lnt Can void Init_Can BYTE BTRO BYTE BTR1 Parameters BTRO BUS TIMING REGISTER O BTR1 BUS TIMING REGISTER 1 This function sets configuration parameters to initialize the CAN controller Configuration parameters include baud rate Valid Baud rate codes can be taken from the Baud Rate Table Korenix Korenix Library Reference EE This function will also set up the Interrupt Enable Register Acceptance Code Register Acceptance Mask Register and Output Control Register LJ Can_Chip_Reset void Can_Chip_Reset void This function resets the CAN controller to default state The transmitting and receiving of messages will be canceled and messages in the driver buffer will be cleared as well LJ Can_Send_Message void Can_Send_Message CANMsg MsgToSend Parameters MsgToSend Message to transmit Please refer to Structure for details LJ Can_Receive_Message void Can_Receive_Message CANMsg MsgToRead Parameters Msg
2. will work successfully U Do the following steps to setup the driver 1 2 Login in as root username root password korenix Default CanBus code are built in jetbox linux environment Go to the path CanBus and you will see the follow directory root localhost cd CanBus root localhost CanBus Is X anp le l ibra ry In the library directory You will see the two files below root localhost library ls libmycanbyus so 1 0 0 mycanbus h libmycanbus so 1 0 0 It contains all CanBus functions that user can use it to program mycanbus h It defines CanBus structure message type and baud rates settings A All details will be shown in Chapter 4 In the example directory You will see the files below root localhost exanple 11 total 20 rwxr r 1 root root 2131 2012 08 28 05 20 canrev c rwxr r root root 2538 2012 08 28 05 23 cantest c rwxr r 1 root root 1263 2012 08 10 13 11 cant st h twxt r root root 33 2012 08 28 22 28 lcankey rwxr r root root 211 2012 08 28 23 08 Makefile Korenix Software Configuration Call make to compile files and make install to install library to usr lib A All details will be shown in next session 3 2 Example CANBus example for Linux is a simple CAN monitor for viewing and transmitting CAN messages When you call make and make install to compile install all need files It will generate two sample fil
3. CANbus Value Terminator Resistor 120 Q The minimum speed is 20k bps The maximum speed is 1M bps But when CANBUS terminator is disabled the maximize speed of CANBUS is 125k bps If you want to use high speed 1M bps please enable terminator sss eee eee e eee e 6 Note 3 More information of Status is given in the data sheet of SJA 1000 in section 6 4 5 Status Register SRI 11 Note 4 More information of Status is given in the data sheet of SJA 1000 in section 6 4 15 Acceptance Filter sese eee 11 Note 5 More information of Status is given in the data sheet of SJA 1000 in section 6 4 6 Interrupt Register llorare 12 Note 6 More information of Status is given in the data sheet of SJA 1000 in section 6 4 3 Mod Register MOD sse 13 Note 7 More information of Status is given in the data sheet of SJA 1000 in section 6 4 4 Command Register CMR 13 Note 8 Please refer to Error Code Table for details sese 14 Note 9 More information of Status is given in the data sheet of SJA 1000 in SECTION 6 4 iii iaa 14 Note 10 More information of Status is given in the data sheet of SJA 1000 a adle lR 6 r ci n 14 Note 11 More information of Status is given in the data sheet of SJA 1000 IN SECTION O lcr a nan hiss meta dara 15 Korenix Appendix Note 12 More information of Status is given in the data sheet of SJA 1000 IN SCCUON c aiii iii 15 Note 13 More information on setting the bit rate is given in the data sheet of SIA 1000 in
4. L BYTE Can_Get_EWL void Return The value of Error Warning Limit Register The error warning limit can be defined within this register The default value after hardware reset is 96 AX note 10 More information of Status is given in the data sheet of SJA 1000 in section 6 4 10 Korenix Korenix Library Reference O Can_Get_TXERROR_COUNTER BYTE Can_Get_TXERROR_COUNTER void Return The value of transmit error The TX error counter register reflects the current value of the transmit error counter Anote 11 More information of Status is given in the data sheet of SJA 1000 in section 6 4 12 LJ Can_Get_RXERROR_COUNTER BYTE Can_Get_RXERROR_COUNTER void Return The value of receive error The RX error counter register reflects the current value of the receive error counter Anote 12 More information of Status is given in the data sheet of SJA 1000 in section 6 4 11 4 3 Structure The CanPort API defines the following structures CANMsg Defines a CAN message typedef struct DWORD ID BYTE MSGTYPE BYTE LEN BYTE DATA 8 CANMsg Korenix Korenix Library Reference ID 11 29 bit CAN identifier MSGTYPE Bit mask indicating the type of the message Several message types can be combined Identifer Value Description MSGTYPE_STANDARD OOh Data Frame CAN message with data contents and an 11 bit CAN ID MSGTYPE_RTR 01h Remote Transmit Request RTR MSGTYPE_EXTENDED 02h Data Frame CAN mes
5. ToRead Returns a CAN message from the receive queue LJ Can Status Report BYTE Can_Status_Report void Return Status of CAN controller Get the current status of the CAN controller Korenix Korenix Library Reference Anote 3 More information of Status is given in the data sheet of SJA 1000 in section 6 4 5 Status Register SR LJ Can Set Filter void Can_Set_Filter DWORD dwACR DWORD dwAMR This function sets the Acceptance Code and Acceptance Mask of the CAN controller The CAN controller must set to reset mode when calling the function Anote 4 More information of Status is given in the data sheet of SJA 1000 in section 6 4 15 Acceptance Filter Parameters dwACR Acceptance Code Register dwAMR Acceptance Mask Register Example The following example shows the parameter values for dwACR and dwAMR in order to accept only the Data messages of standard frame in the range 110h to 113h dwACR 001 0001 0000 dwAMR 000 0000 0011 Valid IDs 001 0001 00xx ID 110h 001 0001 0000 ID 111h 001 0001 0001 ID 112h 001 0001 0010 ID 113h 001 0001 0011 So the value of dwACR is 0x221FFFFF and the value of dwAMR is Ox007FFFFF Korenix Korenix Library Reference L Can Reset Filter void Can_Reset_Filter void This function reset the Acceptance Code and Acceptance Mask Register of the CAN to default value It means accept all CAN message LJ Can_Interrupt_Status BYTE Can_Interrupt_Status void Ret
6. You can set the base address and access to the internal resources of the SJA1000 CAN controller chip The SJA1000 chip access is multiplexed in such a way that the host must first write to 300h the internal address of the CAN chip and after that perform a write to address 301h with the actual data to be written into the desired memory location Address 302h is a hardware reset function of the SJA1000 Performing a read or write to this address Korenix Introduction SI will cause a hardware reset to the CAN controller You may need to reset the chip in case of an unrecoverable error in the CAN controller chip And your can use interrupt the main processor when a message is received or transmitted if interrupts are enabled on the JetBox 8152 By using interrupts you can write powerful code to CAN Base Address 300H Data Of Address 301H Hardware Reset Of SJA1000 Chips 302H Interrupt Require Quest Example Programming Write 300H to the CAN controller Control byte located in the on chip address 0 The Example is listed below Outportb 0x300 0x00 Write CAN Address 0 Control Register Outportb 0x301 0x78 Write Data of CAN Address 0 Control Register And please see SJA1000 pdf for further information of the SJA1000 chip Korenix Introduction Chapter 2 Hardware Configuration 2 1 Pin Assignment The CANBUS is use DB9 standard connector The following tables show the CANBUS signal connections of this
7. connector N C N C Ground Digital Ground Case Ground CANBUS CANBUS Signal Description 1 N C ine wi 6 N C 2 CAN L Dominant Low 7 CAN H Dominant High 3 CAN Ground Isolated Ground Fem 8 N C 4 9 Ln Anote 1 The CANBUS DB9 pin out conforms to the ISO 11898 2 standard 2 2 Jumper Setting JP6 JP6 CANBUS Terminal Resistor Selection fin JP a E p j H v i p J pa K K A a z s Q o i OT yi BPS 12 3 Po K vei ii i E x j CANBUS CANBUS Terminator Terminator Disabled Enabled Factory preset A note 2 The JP6 is the CANbus termination jumper Only two termination jumpers should be closed at the endpoints of the CANbus Value Terminator Resistor 120 Q The minimum speed is 20k bps The maximum speed is 1M bps But when CANBUS terminator is disabled the maximize speed of CANBUS is 125k bps If you want to use high speed 1M bps please enable terminator Korenix Hardware Configuration La Chapter 3 Software Configuration 3 1 Installation L Prerequisites To make CANBus work correctly We have to install three components first Make sure your network is connected 1 GCC call yum install gcc 2 OpenSSL call yum install openssl 3 OpenSSL devel call yum install openssl devel i386 After install these components the CANBUS library and follow example code
8. es cantest and canrcv root localhost example 11 total 36 twxt x1r x root root 7148 2012 08 29 00 20 canrey rwxr r root root 2131 2012 08 28 05 20 canrev c rwxr xr x root root 6782 2012 08 29 00 20 cantest rwxr r root root 2538 2012 08 28 05 23 cantest c rwxt 1t root root 1263 2012 08 10 13 11 cantest h rwxr r root root 33 2012 08 28 22 28 lcankey l S AT T root root 211 2012 08 28 23 08 Makefile L cantest There will be four command as below cantest i Initial CanBus Chip and set baud rate to 125K cantest r Reset CanBus Chip cantest s Get CanBus status cantest w Write CAN message We use standard message type in this example LJ canrcv This example show you how to receive CAN message from other CANBus Before to receive CAN messages you have to reset CAN chip first and initial it root localhost example canrev anlD 0x604 Type 0x00 Length 8 ata 0x22 0x11 0x10 0x01 Ox6c Ox6f 0x61 0x64 anlD 0x704 Type Ox01 Length 0 ata anID 0x602 Type 0x02 Length 8 ata 0x22 Ox0c 0x20 0x00 Ox01 0x00 0x00 0x00 anID 0x204 Type 0x00 Length 1 Data Oxa Korenix Software Configuration ES Chapter 4 Korenix Library Reference This section shows how to use Korenix CANbus Library to develop your program When you call make install in the example directory the library will be installed to the usr lib path 4 1 Howto Use Library
9. korenix JetBox 8152 Linux CANBus User Manual www korenix com Copyright Notice Copyright 2012 Korenix Technology Co Ltd All rights reserved Reproduction without permission is prohibited Information provided in this manual is intended to be accurate and reliable However the original manufacturer assumes no responsibility for its use or for any infringements upon the rights of third parties that may result from its use The material in this document is for product information only and is subject to change without notice While reasonable efforts have been made in the preparation of this document to assure its accuracy Korenix assumes no liabilities resulting from errors or omissions in this document or from the use of the information contained herein Korenix reserves the right to make changes in the product design without notice to its users Acknowledgments Korenix is a registered trademark of Korenix Technology Co Ltd All other trademarks or registered marks in the manual belong to their respective manufacturers Korenix Table of Content Table of Content Copyright Notice sss see ee eee 2 o Sats sense een 2 Table eiee T 3 Chapter i MTOR CUON sen intention rinose 4 Chapter 2 Hardware Configuration sees eee eee eee eee eee 6 2 1 TORE TS lal nooo 6 2 2 Jumper Setting Piamonte 6 Chapter 3 Software Configuration dida 7 3 1 TE 21T 1 ae A aE Ae 7 3 2 Example atch ae en en mn 8 Chapter 4 K
10. orenix Library Reference ss 9 4 1 How to Use Libra ius iii 9 4 2 FUNCUON Simat il ee RE 9 4 3 SSL QU CUUNG ci innoirea e Taaa S O E E a Saa Oa Ee Troan Sa aSa 15 Chapter 5 ADDED denim nn ones 17 5 1 Band Rate Tabla iii 17 5 2 Error Code Table nacida identitaire dd dt 18 5 3 A o II en ancien b on nenssetaserentete dati 19 5 4 Revisi n MIS me dd emo dues 20 5 5 Customer Service iebseseelancetceseleveceeadlugengeseluversbersserstecseerdsaccs 20 Korenix Table of Content Chapter 1 Introduction The JetBox 8152 has two ports for I O communications One RS 232 422 485 port and one CANBUS port The CAN Controller Area Network is a serial bus system especially suited for networking intelligent 1 0 devices as well as sensors and actuators within a machine or plant Characterized by its multi master protocol real time capability error correction high noise immunity and the existence of many different silicon components the CAN serial bus system originally developed by Bosch for use in automobiles is increasingly being used in industrial automation CANbus This section describes how to program and use the CANBUS It provides a description of the 1 0 memory map of the chip and discussion of the internal registers to aid you in programming your CAN controller chip D amp A SJA1000 Buffer CAN BUS Decoder Controller OPTO Isolation Defined Memory Mapping and Interrupt The CANBUS occupies 2 bytes of memory space
11. sage with data contents according to CAN 2 0B standard 29 bit CAN ID LEN Number of data bytes in a data message Data Length Code DATA Data bytes of a CAN message The size can be 0 to 8 bytes Korenix Korenix Library Reference Chapter 5 Appendix 5 1 Baud Rate Table Baud Rate bps Predefined BTRO BTR1 BTRO BTR1 BAUD_5K BAUD_10K BAUD _20K BAUD _50K 100K BAUD _100K 125K BAUD _125K 250K BAUD _ 250K 500K BAUD_500K 00 1C 1000K BAUD_1M 00 14 The following Baud Rates are also common Baud Rate bps BTRO BTR1 33 33K 1D 14 47 6K 14 14 83 33K 4B 14 95 23K C3 4E 800K 00 16 Anote 13 More information on setting the bit rate is given in the data sheet of SJA 1000 in section 6 5 Korenix Appendix 5 2 Error Code Table an are rs are ara ara ori oro omamen T1 ee 0 pme ee 0 pores A 6 be A eme O DN nn ones ek mens De sn se eme I CO CD CTI A 0 40 0 dete es b kh bo bb CRC sequence rf h ha b fo fo came kbh ff p bho acknowledge slot CO e e p h h eromena OE e e b h atte S 1 0 0 1 0 intermission 1 0 0 0 1 active error flag 1 0 1 1 0 passive error flag 1 0 0 1 1 tolerate dominant bits 1 0 1 1 1 error delimiter 1 1 1 0 0 overload flag 5 3 Notes Note 1 The CANBUS DB9 pin out conforms to the ISO 11898 2 standard 6 Note 2 The JP6 is the CANbus termination jumper Only two termination jumpers should be closed at the endpoints of the
12. section 6 5 ria 17 Note You can get the SJA1000 datasheet from following website http www nxp com documents data sheet SJA1000 pdf 5 4 Revision history VO 1 by 2012 9 4 Change default CANbus terminator jump setting JP6 to enable 5 5 Customer Service Korenix Technologies Co Ltd Business service sales korenix com Customer service koreCARE korenix com Korenix Appendix
13. urn The value of Interrupt Register Anote 5 More information of Status is given in the data sheet of SJA 1000 in section 6 4 6 Interrupt Register IR U Can_Mode_Set void Can_Mode_Set BYTE bMode Parameters bMode operation mode Description SLEEP_MODE ACCEPT_FILTER_MODE SELF_TEST_MODE LISTEN_ONLY_MODE RESET_MODE NORMAL_MODE Value 0x10 0x08 0x04 0x02 0x01 0x00 Korenix Korenix Library Reference AX note 6 More information of Status is given in the data sheet of SJA 1000 in section 6 4 3 Mod Register MOD LJ Can Set BTR void Can_Set_BTR BYTE BTRO BYTE BTR1 Parameters BTRO BUS TIMING REGISTER O BTR1 BUS TIMING REGISTER 1 This function only sets the baud rate to CAN controller L Can Set Command void Can_Set_Command BYTE bCmd Parameters bCmd Command mode Description Value CLEAR_DATA_OVERRUN 0x08 RELEASE_RECEIVE_BUFFER 0x04 ABORT_TRANSMISSION 0x02 TRANSMISSION_REQUEST 0x01 Anote 7 More information of Status is given in the data sheet of SJA 1000 in section 6 4 4 Command Register CMR Korenix Korenix Library Reference LJ Can_Get_ECR BYTE Can_Get_ECR void Return The value of Error Code Capture Register Anote 8 Please refer to Error Code Table for details Anote 9 More information of Status is given in the data sheet of SJA 1000 in section 6 4 9 LJ Can_Get_ALC BYTE Can_Get_ALC void Return The value of Arbitration Lost Capture Register LJ Can_Get_EW
Download Pdf Manuals
Related Search
Related Contents
manual do proprietário Kingston Technology ValueRAM 16GB DDR3-1333 Viewer for Illustrator Manual del Usuario Haier HWDC1000TXVE User's Manual Thomson 61DLW616 DLP projection TV eCLINICIAN EMR User Guide GE Monogram ZKD910 Surge Protector User Manual 8. Hybrid simulation in Alecsis Copyright © All rights reserved.
Failed to retrieve file