Research on CAN Bus Test Mode Based on Single-chip Microcomputer

Source: Internet
Author: User

Abstract: fieldbus has become the most active hotspot in the field of data bus, and CAN bus is recognized as one of the most promising Fieldbus, the Design and debugging of CAN bus nodes are the focus of the design of CAN bus communication systems. This paper introduces the CAN controller integrated into the single-chip microcomputer of, designs a CAN communication node based on the single-chip microcomputer of, and provides the software design program of the test mode of the CAN node, it can be used for the test of the CAN bus module to save test time.
Key words: C8051F040; CAN bus; test mode; CAN controller

The field bus can meet the needs of process control and manufacturing automation at the same time. Therefore, the Field Bus has become the most active field in the field of data bus. The Research and Application of fieldbus has become a hotspot in the field of data bus. The CAN Bus (Controller Area Network) is a type of serial communication network that supports distributed control and real-time control. CAN bus is a serial communication protocol developed by German doctor in 1980s to solve the data communication between many control and test instruments in modern vehicles. Because of its high performance, high reliability, and unique design, the CAN bus has been paid more and more attention, and its application fields are no longer limited to the automotive industry, it has developed into the process industry, machinery industry, textile industry, agricultural machinery, sensors, aerospace and other fields. It is recognized as one of the most promising Fieldbus.

1 Introduction
The 51 series single-chip microcomputer developed by cygnal Corporation is a fully integrated hybrid signal system microcontroller. It is integrated into a CAN bus controller that can realize full functions of can, and fully complies with the can specifications 2.0a and 2.0b. In this paper, a CAN communication node hardware circuit is designed by using the CAN controller integrated on the single-chip microcomputer and an external can transceiver (pca82c250). Then, the implementation of the test mode of the CAN controller is introduced in detail, it can be used for debugging and testing of CAN communication nodes.

2 CAN controller integrated on Single-chip Microcomputer
The CAN controller consists of the CAN core, message storage, message processor, control register, and Module Interface. The can core is used for Protocol control and serial message conversion. The message memory is used to store message objects and tokens. The message processor is used to control data transmission between the can core and the message memory; the control register is used to control and configure the CAN controller. The module interface is used to exchange data between the MCU and the CAN controller. 32 message objects can be stored in the message memory of the CAN controller integrated on the single-chip microcomputer, and can be configured as sending or receiving objects. The CAN bus protocol processing is independently implemented by the CAN controller without MCU intervention. Therefore, the CPU bandwidth occupied by CAN communication is very small, as shown in principle 1 of CAN controller integrated.


3. CAN controller Working Mode
The CAN controller integrated on the single-chip microcomputer has two working modes: normal working mode and test mode. You can enter the test mode by entering the test position 1 in the CAN controller register. In test mode, tx1, tx0, lback, silent, and basic bits in test registers are writable. After the test is set to 0, all functions of the test register will be disabled. The test mode can be subdivided into four working modes: The Silence mode (also called the monitoring mode), the return mode, the basic mode, and the combination of the send-back and silence modes. Pass the test register
You can set the can core to the Silence mode. In silence mode, the can core can receive valid data frames and valid remote frames, but it can only send hidden bits on the bus instead of transmitting them. Figure 2 shows the connection between the can_tx and can_rx signals and the can core in Silence mode. You can set the can core to the return mode by setting the lback position 1 of the test register. In the send-back mode, the can core treats the messages it sends as received messages and stores them in the receiving cache.

Figure 3 shows the connection between the can_tx and can_rx signals and the can core in the return mode. By setting lback and silent to 1 at the same time, you can combine the return mode and Silence mode. This mode can be applied to the hot self-check. You can perform self-check on the CAN node without affecting the operation of the CAN System. In this mode, the can_rx pin is disconnected from the can core, and the can_tx pin is kept as a hidden bit. Figure 4 shows the connection between the can_tx and can_rx signals and the can core in this mode. If the basic in the test register is set to 1, the can core will work in the basic mode. In this mode, the message memory does not work, that is, the if1 register is used as the transmission cache instead of the Message Queue cache for data exchange, and the if2 register is used as the receiving cache.

4 CAN communication node hardware design
The CAN controller integrated on is a protocol controller and cannot provide physical layer drivers. You need an external can transceiver to connect to the can network and communicate with other nodes. This document uses the pca82c250 transceiver as the physical layer driver. If an optical fiber separation device is added between the CAN controller and pca82c250, the system stability and reliability can be improved, but this increases the complexity of the system. The purpose of this article is to debug the test mode of the CAN controller, so no optical coupling isolation device is used. Figure 5 shows the principle of the CAN communication node.

5. Software Design
The Software Design of the CAN communication node based on consists of three parts: CAN node initialization, message sending and message receiving. Familiar with the design of these three programs, you can write common CAN communication programs.
5.1 can Initialization
The general steps for initializing a CAN controller are as follows:
(1) set the sfrpage register to can0_page.
(2) set the init and CCE bits of the can0cn register to "1 ".
(3) set timing parameters.
(4) Start the CAN controller.
As this article is about the test mode, we need to enter the test mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.