1 The SJA1000 CAN Controller and Linux Driver Cristiano Brudna Universität Ulm Fakultät für Informatik Abteilung Rechnerstrukturen.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

You have been given a mission and a code. Use the code to complete the mission and you will save the world from obliteration…
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 10 second questions
£1 Million £500,000 £250,000 £125,000 £64,000 £32,000 £16,000 £8,000 £4,000 £2,000 £1,000 £500 £300 £200 £100 Welcome.
Welcome to Who Wants to be a Millionaire
ZMQS ZMQS
EUSART Serial Communication.
Report Card P Only 4 files are exported in SAMS, but there are at least 7 tables could be exported in WebSAMS. Report Card P contains 4 functions: Extract,
Contents Overview Data Information Frame Format Protocol
1 Peripheral Component Interconnect (PCI). 2 PCI based System.
Introduction to CAN.
Course Introduction Purpose This training course provides an overview of the CAN peripheral in Renesas M16C and R8C microcontrollers that is used to build.
Computer Structure.
Figure 12–1 Basic computer block diagram.
Microprocessor Architecture Pipelined Architecture
1 Operating Systems Input/Output Management. 2 What is the I/O System A collection of devices that different sub- systems of a computer use to communicate.
ABC Technology Project
CAN © CiA Node 2 Node 3 Node 4 Node n Node 1 Ld Ld = Drop Length Lt Lt = Trunk Length ISO Topology.
VOORBLAD.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
© 2012 National Heart Foundation of Australia. Slide 2.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
Equal or Not. Equal or Not
Gursharan Singh Tatla PIN DIAGRAM OF 8086 Gursharan Singh Tatla Gursharan Singh Tatla
Week 1.
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
©2004 Brooks/Cole FIGURES FOR CHAPTER 12 REGISTERS AND COUNTERS Click the mouse to move to the next page. Use the ESC key to exit this chapter. This chapter.
Connecting LANs, Backbone Networks, and Virtual LANs
1 Unit 1 Kinematics Chapter 1 Day
PSSA Preparation.
VPN AND REMOTE ACCESS Mohammad S. Hasan 1 VPN and Remote Access.
How Cells Obtain Energy from Food
TCP/IP Protocol Suite 1 Chapter 18 Upon completion you will be able to: Remote Login: Telnet Understand how TELNET works Understand the role of NVT in.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
1 SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004.
© 2008, Renesas Technology America, Inc. All Rights Reserved The RCAN-ET peripheral and the CAN API SH2 & SH2A MCUs V 1.2 Mar 2010.
Lecture 14 Controller Area Network (CAN) NCHUEE 720A Lab Prof. Jichiang Tsai.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This training course provides an overview of Message Frames.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose This module provides an overview of sophisticated peripheral.
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
Controller Area Network
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
Serial mode of data transfer
SPI Protocol and DAC Interfacing
Serial Communication Interface: Using 8251
Presentation transcript:

1 The SJA1000 CAN Controller and Linux Driver Cristiano Brudna Universität Ulm Fakultät für Informatik Abteilung Rechnerstrukturen

2 Contents "The SJA1000 –Physical connection, registers, message formats, filtering. "SJA1000 Linux Driver –How to send and receive messages, special functions.

3 SJA1000 Basic Features "Pin and electrical compatibility to the PCA82C200 "Extended (29 bit) and Standard (11 bit) Frame Formats "Bit rate up to 1 Mbit/s "Buffer: –Receive buffer: 64-byte ringbuffer –Transmit buffer: 1 message

4 Physical Connection Microcontroller SJA1000 Transceiver (PCA82C250) TX RX CAN_H CAN_L CAN bus

5 Modes of Operation "BasicCAN (compatible with PCA82C200) – Only Standard Frame Format (11 bit identifiers) – Extended Frame Format is tolerated "PeliCAN – Standard and Extended Frame Format (11 and 29 bit identifiers)

6 Registers (PeliCAN mode) "8 bit registers "Registers for configuration and control –Mode, Command, Interrupt Enable, Bus Timing 0/1, Output Control, Acceptance Code, Acceptance Mask "Registers that provide status –Status, Interrupt, RX Error Counter, TX Error Counter, Error Warning Limit, Error Code Capture, Arbitration Lost capture, RX Message Counter, RX Buffer Start Address, Clock Divider

7 Mode Register "Sleep mode –Goal: save energy –First message will be lost! "Acceptance Filter Mode "Self Test Mode "Listen Only Mode –No ancknowledge is sent, error counters stop "Reset Mode

8 Interrupts "Interrupts provided: –Bus Error –Arbitration Lost –Error Passive –Wake-up –Data Overrun –Error Warning –Transmit –Receive "Can be idividually enabled/disabled

9 Bus Timing 0/1 Registers "Can be written only in RESET MODE "Bus Timing 0 –BTR0.7 to 6: Synchronization Jump Width (2 bits) –BTR0.5 to 0: Baud Rate Prescaler (6 bits), define TQ "Bus Timing 1 –BTR1.7: Sampling (1 bit), 1 or 3 times –BTR1.6 to 4: Time Segment 1 (4 bits) –BTR1.3 to 0: Time Segment 2 (3 bits)

10 Bus Timing 0/1 Registers (cont) SYNC SEG TSEG1 TSEG2 Sample point(s) Nominal bit time = 1 TQ Time quantum (TQ) is used to define segments

11 Error registers "RX error counter: number of receive errors "TX error counter: number of transmit errors "Error code capture: identify the type of error occurred during transmition/reception

12 Data Frame, Remote Frame "Frame Information (1 byte): –FF: frame format –RTR: remote transmission request –DLC: data length code "Identifier: –Standard frame format: 2 bytes –Extended frame format: 4 bytes "Data Bytes: 0-8 bytes FFRTRXXDLC.3DLC.2DLC.1DLC.0

13 Message Format Tx frame information Tx identifier 1 Tx identifier 2 Tx data byte 1 Tx data byte 2 Tx data byte 3 Tx data byte 4 Tx data byte 5 Tx data byte 6 Tx data byte 7 Tx data byte 8 Tx frame information Tx identifier 1 Tx identifier 2 Tx data byte 1 Tx data byte 2 Tx data byte 3 Tx data byte 4 Tx data byte 5 Tx data byte 6 Tx data byte 7 Tx data byte 8 Tx identifier 3 Tx identifier 4 Standard Frame Extended Frame

14 Filtering "Two modes of filtering: –Single filter: 32-bit filter "Standard Frame: identifier + RTR + data1 + data2 "Extended Frame: identifier + RTR –Dual filter: at least one filter must match "SF: filter 1(ID + RTR + data1), filter 2 (ID + RTR) "EF: filter 1and 2 (2 upper bytes of the ID) "Acceptance Mask Register: define relevant bits ('1' = don't care) "Acceptance Code Register: define bits to be matched

15 Single Filter for Extended Frame Format ID.4ID.3ID.2ID.1ID.0 Message ID AMR3.7AMR3.6AMR3.5 AMR3.4 AMR3.3AMR3.2 X X Acceptance Mask Register ACR3.7ACR3.6ACR3.5ACR3.4ACR3.3ACR3.2 XX Acceptance Code Register AMR 2 AMR 1 AMR 0 ID.12 to 5ID.20 to 13ID.28 to 21 RTR ACR 2ACR 1ACR 0 Byte 0 Byte 1 Byte 2Byte 3

16 Single Filter Example Message ID Acceptance Mask Register Acceptance Code Register Accepted "1" ID.12 to 5ID.20 to 13ID.28 to 21 "0" Byte 3 Byte 2Byte 1 Byte 0

17 Using the SJA1000 Linux driver "The driver uses receive and transmit interrupts and read and write buffers "File operations for applications: open(), close(), read(), write(), ioctl(), and select().

18 Using the SJA1000 Linux driver File operations (1) "Open: provide blocking and non-blocking modes can = open("/dev/can", O_RDWR); can = open("/dev/can", O_RDWR | O_NONBLOCK); "Close: close(can);

19 Using the SJA1000 Linux driver CAN message data structure typedef struct { CanId id; // identifier (11 or 29 bits) int type; // standard (0) or extended frame (1) int rtr; // remote transmission request (1 when true) int len; // data length 0..8 unsigned char d[8]; // data bytes struct timeval timestamp; // timestamp for received messages in the format of [seconds, microseconds] since Epoch (january ). } canmsg;

20 Using the SJA1000 Linux driver File operations (2) "Read: return a message from the read buffer –Return '32' when a message is available and -EAGAIN when there is no message. ret = read(can, &msg, sizeof(canmsg)); "Write: write a message to the driver. –Return '32' when the message is succesfully stored in the transmit buffer and -EAGAIN when the buffer is full. ret = write(can, &msg, sizeof(canmsg));

21 Using the SJA1000 Linux driver File operations (3) "ioctl: specific control operations. unsigned long baud_rate = B1000; ioctl(can, CAN_IOCSBAUD, &baud_rate); "Supported operations: –CAN_IOCSBAUD: set baud rate. The following constants are used to set it: B1000 (1Mbit/s), B500 (500kbit/s), B250 (250kbit/s), B125 (125kbit/s), B20 (20kbit/s).

22 Using the SJA1000 Linux driver File operations (4) "Supported operations: –CAN_IOCSAMASK: set a 32-bit acceptance mask. –CAN_IOCSACODE: set a 32-bit acceptance code. –CAN_IOCCRBUF: clear read buffer. –CAN_IOCCWBUF: clear write buffer. –CAN_IOCRTTS: read the timestamp of the last transmitted message. The timestamp is returned in a timeval data structure.

23 Using the SJA1000 Linux driver File operations (5) –CAN_IOCSACTIVE: set active mode. –CAN_IOCSPASSIVE: set passive mode. –CAN_IOCRREG: read a SJA1000 register. The most useful ones for applications are 'ERROR_CODE_CAPTURE' 'RX_ERROR_COUNTER' 'TX_ERROR_COUNTER'