Design of CAN communication module based on single chip microcomputer and MCP2510

Publisher:素雅之韵Latest update time:2012-04-12 Source: 维库开发网 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

CAN (Controller Area Network) bus, or controller area network. Due to its high performance, high reliability and unique design, CAN bus is gaining more and more attention. Bosch of Germany originally designed CAN bus for automobile monitoring and control system. Now, its application has been developed in the fields of process industry, machinery industry, textile industry, agricultural machinery, robot, CNC machine tool, medical equipment and sensor. CAN bus has formed international standard and has been recognized as one of the most promising field buses. CAN bus specification has been formulated as international standard ISO11898 by International Organization for Standardization, and has been supported by many semiconductor device manufacturers, who have launched various products with integrated CAN protocol. Intelligent node of CAN bus system is the receiving and sending station of messages on the network, which is generally composed of single chip microcomputer and CAN controller or the combination of the two.

MCP2510 is an independent programmable CAN controller chip produced by Microchip. This paper will introduce the new independent CAN communication controller MCP2510 and give its application example in the intelligent node of CAN bus system.

1 Introduction to MCP2510 chip

MCP2510 is a CAN controller with SPI interface, DIP package is shown in Figure 1. It supports CAN technical specification V2.0A/B. It can send or receive standard and extended information frames, and has the functions of receiving filtering and information management. MCP2510 transmits data with MCU through SI interface, and the maximum data transmission rate can reach 5 Mbps. MCU can communicate with other MCU units on CAN bus through MCP2510. MCP2510 contains 3 sending buffers and 2 receiving buffers, and also has flexible interrupt management capabilities. These features make it very easy for MCU to operate CAN bus.

1.1 Main features of MCP2510

◇Support CANV2. OA/B;

◇With SPI interface, supporting SPI modes 0, 0 and 1, 1;

◇ Contains 3 transmit buffers and 2 receive buffers, and their priorities can be programmed;

◇With 6 receiving filters and 2 receiving filter shields;

◇Have flexible interrupt management capabilities;

◇Using low-power CMOS process technology, its operating voltage range is 3.0~5.5V, effective current is 5mA, and maintenance current is 10μA;

◇Working temperature range is -40~+125℃.

1.2 Structure and working principle

MCP2510 has three packaging forms: PDIP, SOIC and TSSOP. Figure 2 is the internal structure diagram of MCP2510. The CAN protocol machine is responsible for the interface with the CAN bus, the SPI interface logic is used to realize the communication with the MCU, and the register, buffer group and control logic are used to complete various settings and operation controls. Now, the functions and principles of each part are introduced in combination with its working process.

(1) Sending and receiving operations

The transmission operation of MCP2510 is realized through three transmission buffers. These three transmission buffers each occupy 14 bytes of SRAM. The first byte is the control register TXBNCTRL, which is used to set the conditions for information transmission and gives the transmission status of the information; the second to sixth bytes are used to store standard and extended identifiers and arbitration information; the last 8 bytes are used to store the data information to be sent. Before sending, these registers must be initialized. [page]

(2) Interrupt management

MCP2510 has 8 interrupt sources, including transmit interrupt, receive interrupt, error interrupt and bus wake-up interrupt. The interrupt enable register (CANINTE) and interrupt mask register (CANINTF) can be used to conveniently manage various interrupts. When an interrupt occurs, the INT pin becomes low and remains at a low level until the MCU clears the interrupt.

(3) Error detection

The CAN protocol has detection functions such as CRCF error, response error, form error, bit error and stuffing error. MCP2510 contains two error counters: receive error counter (REC) and transmit error counter (TEC). Therefore, for any node in the network, it is possible that it will be in one of the three states: error-activated, error-accepted and bus-disconnected due to different values ​​of the error counters.

2 Application examples of MCP2510 in intelligent nodes

A CAN bus distributed measurement and control network can be constructed by using MCP2510 and CAN bus transceiver TJA1050. The system can include a main controller and multiple node controllers. Such node controllers can monitor the current, voltage and ambient temperature of the motor. Its structure is shown in Figure 3.

This network topology adopts bus structure and passive tap connection, and has simple structure and low cost, so the system reliability is high. Its information transmission adopts CAN communication protocol, and the communication medium adopts twisted pair. Since the CAN bus is based on the encoding of the sent message, the CAN control node is not encoded, so the system is more expandable, and adding or deleting the control node on the CAN bus will not have any impact on the other nodes of the system.

The MCU of the node controller can use a microprocessor with an SPI interface or a microprocessor without an SPI interface. This system uses a microprocessor AT89C51 without an SPI interface. AT89C51 can be directly connected to the SPI interface of the CAN controller through the P1 port, and the SPI interface protocol is implemented using a software algorithm. The CAN bus transceiver TJA1050 serves as the interface between MCP2510 and the physical bus. If the anti-interference ability of the system needs to be further improved, an optoelectronic isolator can be added between MCP2510 and TJA1050.

The circuit schematic diagram of the intelligent node is shown in Figure 4.

2.1 Software Design

Before the MCP2510 works properly, it needs to be initialized correctly, including setting the data transmission rate of the SPI interface, the baud rate of the CAN communication, the receiving filter and mask of the MCP2510, and the transmit and receive interrupt enable flags, etc. Unlike the SJA1000, the microcontroller must use the built-in read and write commands of the MCP2510 to operate the receive buffer and transmit buffer of the MCP2510 through the SPI interface. The read and write command timing diagrams are shown in Figures 5 and 6.

In this paper, MCP2510 mainly adopts interrupt mode to receive and send bus data. The whole system main sequence provides two kinds of interrupts: timer interrupt and external interrupt. The interrupt subroutine of timer interrupt is mainly responsible for processing A/D data from analog channels AIN0~AIN7, sending "data send request command" to MCP2510 and sending data. The interrupt processing subroutine of external interrupt mainly includes CAN bus error processing subroutine and data receiving subroutine.

2.2 Software design process

The main software design process is shown in Figure 7. The following issues need to be paid attention to when designing the software:

①Because MCP2510 is in the default Configuration mode after initialization, it is necessary to set it to Normal mode after initialization, otherwise MCP2510 will stay in Configuration mode and cannot work normally. Setting MCP2510 to Normal mode can be achieved by using the BitModify (bit modification) 4 instruction built into MCP2510 to write a 0 byte to the CANCTRL control word.

② Before performing any operation on MCP2510, the microprocessor must output a low level to the chip select CS of MCP2510 to enable MCP2510.

③ When executing the "read" operation of MCP2510, after sending the read instruction and its address code, it is still necessary to provide a clock to MCP2510 to receive the "read" data. This can be achieved by sending a 0 byte to MCP2510.

④ After completing any operation on MCP2510, there will be a delay for a period of time so that it has enough time to prepare to receive the command for the next operation to prevent the MCP2510 from being "busy".

3. Conclusion

CAN bus has been recognized as one of the most promising field buses. It is favored by more and more R&D personnel due to its outstanding advantages such as high cost performance and simple implementation. The intelligent node in this paper can connect multiple distributed control systems, and its software and hardware circuit design method is also suitable for the node design of other distributed control systems based on CAN bus.

Keywords:MCU Reference address:Design of CAN communication module based on single chip microcomputer and MCP2510

Previous article:Wireless communication system based on MSP430 microcontroller and nRF905
Next article:Design Technology of Multiple Serial Ports in Single Chip Microcomputer System

Recommended ReadingLatest update time:2024-11-16 18:04

Introduction to the functional modules of PIC microcontroller
PIC16F616 is a 14-pin, 8-bit CMOS microcontroller. It uses a reduced instruction set with only 35 instructions. Due to the use of the Harvard bus structure with separate data bus and instruction bus, most of the instructions are single-cycle instructions except for a few instructions that are not single-cycle. This is
[Microcontroller]
Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer
  Ultrasonic waves are mechanical waves with a frequency of more than 20KHz, and their propagation speed in the air is about 340 m/s (at 20°C). Ultrasonic waves can be generated by ultrasonic sensors. There are two common types of ultrasonic sensors: one is to generate ultrasonic waves electrically, and the other is to
[Microcontroller]
Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer
PIC Microcontroller Introduction_Timer/Counter TMR1 Detailed Explanation and Examples
1 Introduction The basic concept and use of timer/counter TMR0 were introduced above. Now let’s introduce another timer/counter TMR1 in PIC microcontroller. 2. Characteristics of TMR1   TMR1 is 16 bits wide, with a 3-bit frequency divider, and comes with a low-power, low-frequency time base oscillator. The main us
[Microcontroller]
Inventory of 11 common parameters of automotive-grade MCUs
MCU is a core power electronic unit unique to new energy vehicles. It controls the motor to output the specified torque and speed by receiving the vehicle driving control instructions from the VCU, and drives the vehicle to drive. It converts the DC power of the power battery into the required high-voltage AC power
[Embedded]
[MCU] [Learning Log] 51 MCU Learning Log [Day2, 2022.1.10]
Part 1: Digital Tube 1. Basic knowledge 1. Digital tube pin definition (single digital tube) The upper one is the common cathode connection The bottom one is the common anode connection Divide "8" into 8 segments, namely "A, B, C, D, E, F, G, DP (clockwise)", which just correspond to the 8 bytes of the register.
[Microcontroller]
[MCU] [Learning Log] 51 MCU Learning Log [Day2, 2022.1.10]
Design of Virtual Serial Communication of PIC Microcontroller
1. Purpose of this example: This example is completely based on computer software. It uses PROTEUS software to build a single-chip microcomputer system, and uses VB to write a computer control software to communicate serially with the single-chip microcomputer system. The control software on the computer can send a nu
[Microcontroller]
Design of Virtual Serial Communication of PIC Microcontroller
Electric shaver system design based on MSP430x09x MCU
  1 Introduction to MSP430x09x   MSP430x09x is the first 0.9V operating voltage MCU in the MSP430 series. This series is powerful and can be easily applied to micro motor control, infrared transmission, power supply detection and other occasions. In addition, its 0.9V operating characteristics can be widely used in
[Microcontroller]
Electric shaver system design based on MSP430x09x MCU
The breadboard experiment of the microcontroller is another solution in circuit design
Breadboard, in simple terms, is a test board for plugging circuits. The front of the breadboard is full of holes, but all the holes on this board are not independent, but connected together according to certain rules. Take the breadboard in our experiment as an example (you can see its real picture below), divided by
[Power Management]
The breadboard experiment of the microcontroller is another solution in circuit design
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号