A design method for CAN bus communication using TMS320LF2407 DSP & PCL-841
2026-04-06 03:50:06··#1
Abstract : This paper introduces the hardware and software design of CAN bus communication between the TMS320LF2407 DSP and Advantech's PCL-841 data acquisition card, along with its experimental results. It also discusses the problems encountered in the design and their solutions. [b]Keywords[/b]: CAN bus, DSP, PCL-841 1 Introduction Controller Area Network (CAN) is a serial communication bus defined by ISO. It first appeared in the automotive industry in the late 1980s. Its basic design specifications require high bit rates, high immunity to electromagnetic interference, and the ability to detect any errors. Due to these characteristics, the CAN serial communication bus has naturally been widely used in the automotive and aerospace industries. In the past, we used independent microcontrollers and SJA1000 chips for networking. With the development of technology, major chip manufacturers have been researching newer technologies, integrating and modularizing several independent chips, resulting in stronger chip performance, smaller chip area, and lower chip power consumption. The TI TMS320LF2407 DSP (DSP2407 for short) microprocessor chip integrates the function of a CAN controller. When connecting to external circuits, the CAN controller SJA1000 is no longer needed, greatly reducing the development cycle. This article, combining the characteristics of the DSP2407 and the CAN2.0A protocol, introduces a design method for CAN communication between the DSP2407 and the Advantech PCL-841 data acquisition card. 2 System Design and Experimental Results 2.1 Hardware Schematic Diagram and Principle Description of DSP2407 CAN Communication System Figure 1 shows the external circuit diagram of the DSP2407 CAN module. CANJP1 is the CAN_H and CAN_L input terminal. The CAN bus driver PCA82C250 internal driver circuit has a current limiting function to prevent short circuits to the power supply, ground, or load of the transmitting output stage. If the junction temperature exceeds approximately 160 degrees Celsius, the limiting current at the output terminals of the two transmitters inside the chip will decrease. Since the transmitters are the main power-consuming component, this limits the chip's temperature rise. All other parts of the device will continue to operate. The PCA82C250 uses a two-wire differential drive, which helps suppress transient interference. A slope resistor is connected to the Rs pin of the PCA82C250; its value can be adjusted appropriately according to the bus communication speed, typically between 16 and 140 kΩ. Because the PCA82C250's power supply voltage is 5V and the DSP2407's power supply voltage is 3.3V, the PCA82C250's output pin RXD cannot be directly connected to the DSP2407's CANRX; therefore, voltage divider resistors R10 and R11 are used. R6 is a terminating resistor. 2.2 System Software Design To complete the CAN communication between the DSP2407 and PCL-841, the CCS2.2 development platform is used. The system workflow diagram is shown in Figure 2: Figure 2 System Workflow Diagram In Figure 2, PCL-841 receives data from DSP2407 and uploads the data to the host computer, or the host computer sends data to DSP2407 through PCL-841. When PCL-841 starts, the CAN port base address is located at the address starting from DA00:0000H and DA00:0200H. Any CAN port can be selected as the control receiving port of the host computer. The baud rate is selected according to the setting value of DSP2407. Its value algorithm is shown in (1) and (2): Baudrate=ICLK/(BRP+1)*Bit Time (1) Bit Time=(TSEG1+1)+(TSEG2+1)+1 (2) Where ICLK is the CPU frequency of DSP, which is 40MHz here; BRP=1; TSEG1=15; TSEG2=2. Therefore, the CAN bus baudrate=1MHz. The CAN module initialization program for the DSP2407 is as follows: * MDER = 0x0000; * CAN_IMR = 0x0000; * ESR = 0xFFFF; * MCR = 0x1400; while (* GSR & 0x10 == 0) continue; * BCR2 = 0x0001; * BCR1 = 0x00FA; * MCR = 0x0000; while (* GSR & 0x10 != 0) continue; * CAN_IMR = 0x0200; * MDER = 0x003F; * CAN_IFR = 0xFFFF; The program can receive and transmit data by modifying the TCR and RCR registers, thus completing the CAN bus communication between the DSP2407 and the PCL-841. 2.3 Experimental Results When the program is executed, the DSP2407 CAN module first sends data 3344 1122 7788 5566 to PCL-841 via mailbox 5; using interrupt mode, PCL-841 sends data 1111 1111 1111 1111 to mailbox 1 of the DSP; waiting for PCL-841 to send remote frames to mailboxes 2 and 3 of the DSP, the DSP automatically replies with data 0101 0101 0101 0101 and 0202 0202 0202 0202 to PCL-841, completing the experimental operation. The experimental results are shown in Figures 3 and 4. Figure 3 PCL-841 experimental interface Figure 4 CCS2.2 experimental interface As can be seen from the figures, the experimental results fully meet the expected requirements, and the hardware and software design is correct. 3 Problems in the design and solutions 3.1 Hardware circuit (1) In terms of chip selection, it is necessary to choose commonly used chips on the market. Generally speaking, commonly used chips are relatively inexpensive and have relatively more technical support. (2) With the improvement of technology, the power consumption of chips is getting lower and lower, and the power supply voltage of chips is also decreasing, from the original 5V to the current 3.3V and 1.8V. Therefore, the level conversion between different chips is also a key issue in the design. For example, in Figures 1 and 2, a level conversion circuit is used between the DSP and the drive circuit. The voltage from the RXD pin of PCA82C250 is higher than the input voltage of the DSP, so voltage divider resistors R10 and R11 are connected. However, the values of R10 and R11 should also be noted. They should not be too large, otherwise the current will be too small. (3) When drawing PCB circuit boards, electromagnetic compatibility issues and component placement issues need to be considered. The design not only needs to meet the requirements of electromagnetic compatibility, but also needs to consider that the component layout needs to meet the requirements of easy soldering, easy use, and easy maintenance, and make the layout as aesthetically pleasing as possible. After the circuit board is made, before soldering components, it is necessary to check the power supply, ground and other key parts to see if there is a short circuit, so as to avoid unnecessary losses. 3.2 Software Programming (1) Some issues to note when using CCS2.2. When loading the .out file, an error occurs and the system will prompt: "A section of your program falls into a memory region that is not wriable. Check your linker configuration and/or memory map." In general, it is a configuration error in the .cmd file; if the system prompts: "AN IDENTIFIER IN THE EXPRESSION IS INVALID", it is very likely that the register definition in the .h file is different from the register definition in the .c file; if the format is not matched when burning the chip, open Build Options/Linker/Advanced/COFF Output Format and select Default; if using assembly language, the Autoinit Nodel option needs to be selected as No Autoinitialization. (2) The program flowcharts written in some materials may not be completely reasonable and need to be combined with hardware circuit debugging. 4 Conclusion The CAN bus, with its high speed, high reliability and high flexibility, is increasingly used in industrial automatic control. Replacing the original single-function microcontrollers without an integrated CAN controller module, the currently used DSP2407 with an integrated CAN module represents a technological advancement driving the modularization and integration of chips. This article introduces the implementation method of CAN communication between the DSP2407 and the PCL-841, laying the foundation for the further development of CAN bus technology.