Share this

ARM7-based CAN-USB converter design

2026-04-06 07:21:05 · · #1
Introduction During the development of ABS (Anti-lock Braking System) ECUs (Electronic Control Units), calibration techniques are typically used to determine real-time driving and control parameters. Calibration involves uploading and retrieving control algorithm parameters to the ECU using specific commands, allowing for real-time modifications to achieve optimal performance. For automotive ECUs, they usually only have a CAN bus communication interface. To enable direct communication between the host computer and the ECU, and to utilize calibration techniques for ABS ECU development, we designed a CAN-to-USB data converter. CAN communication protocol is a data communication protocol used between measurement and actuation components within automobiles. USB offers the advantages of plug-and-play functionality and high communication speeds, making it very convenient for calibrating communication between the host and slave computers. Our designed data converter uses the NXP LPC2119 ARM7 processor, which successfully enables reliable communication between the host computer and the ECU, as well as calibration of the slave computer. The system hardware design utilizes the LPC2119 ARM7 processor. The LPC2119 is a microcontroller based on a 16/32-bit ARM7TDMI-S CPU that supports real-time emulation and tracing, and features 28/256kB of embedded high-speed Flash memory. Its 128-bit wide memory interface and unique acceleration architecture enable 32-bit code to run at maximum clock speeds. The CH372 USB converter chip is a general-purpose device interface chip for the USB bus. Locally, the CH372 has an 8-bit data bus, read, write, chip select control lines, and interrupt outputs, allowing for easy connection to the controller's system bus. The CH372 integrates the underlying USB communication protocols, and in built-in firmware mode, it automatically handles all transactions at the default endpoint 0. System Design The converter directly uses the 5V power supply from USB. An LM1117 is used to convert the 5V power supply to 3.3V and 1.8V for the ARM processor and its peripheral modules. The logic level output from the CAN controller is converted to a differential level output using a TJA1050. External capacitors are used for decoupling the internal and external power supply nodes of the CH372. 0.01μF capacitors are connected to each voltage pin of the LPC2119 for filtering. In the design of the USB conversion chip, a 4.7kΩ resistor can be selected to release the energy in the electrolytic capacitor in time after power failure, allowing VCC to drop to 0V promptly, ensuring that the CH372 can reliably power on and reset upon the next power-on. For reliable reset of the CH372, the rise time of the power supply voltage from 0V to 5V should be less than 100ms, so the capacitance and resistance values ​​should not be too large. A 15pF monolithic or high-frequency ceramic capacitor is used as the starting capacitor for the clock oscillation circuit of the CH372. The system hardware design block diagram is shown in Figure 1. [IMG=System Hardware Design Block Diagram]/uploadpic/THESIS/2007/12/2007121410471377051M.jpg[/IMG] System Software Design The system program mainly includes the CAN controller driver, the USB control chip CH372 driver, the design of the data read/write buffer, and how to call the CAN and USB read/write functions to achieve better synchronization of data communication. CAN Driver Based on the characteristics of the LPC2119 microprocessor CAN controller, the CAN driver is divided into three layers: 1. Hardware Abstraction Layer: Abstracts the hardware characteristics of the CAN controller using data types and provides an interface for CAN controller hardware operations. It maps the physical layer registers and corresponding addresses, defines the data types of the CAN controller registers, and defines the methods for operating the registers. 2. Function Layer: This layer contains the implementation functions of various CAN controller functions. The functions in this layer use the register operation interface in the hardware abstraction layer to access the CAN controller and implement the various functions provided by the CAN controller. 3. Application Programming Interface (API) Layer: This layer primarily provides three functions: CANinit() for initializing the CAN controller, CANSendData() for sending data, and CANRecieveData() for receiving data. The CH372 driver provides a general-purpose passive parallel interface on the local side of the CH372 chip. The CH372 chip's read/write timing primarily requires the read/write enable signal to have a duration of 2–10 μs, and that commands are written when a0=1 and data is read/written when a0=0. In this design, pin 10 of the LPC2119 is used to represent the various signals of the CH372, and its read/write timing needs to be strictly simulated in software according to its timing requirements. A typical write data subfunction is as follows: In the above program, the order of operations on each port represents the order of the CH372's read/write timing signals. An appropriate delay represents the width of the effective write/read strobe pulse WR/RD, with a typical value of 90 to 10000 ns; we choose 25 μs. Similarly, the write command and read data sub-functions are: USBWriteCMD(uint32 CMD), USBReadData(). Calling these sub-functions provides functions for sending and receiving data: IRQ_CH372(void), UploadUSBData(unin32Length,uint32 Data[]). Circular Buffer In this design, two circular buffers are designed to store USB and CAN data respectively, enabling synchronous transmission. A typical buffer data structure is as follows: Data elements are unsigned 32-bit integers, MAX is the maximum length of the circular buffer, WritePtr is the read pointer, and ReadPtr is the write pointer. The read and write pointers are initialized to writePtr=ReadPtr=0. Data received by the CAN controller is stored in the circular buffer CANRecRinBuf, and then read out and output from the USB end, ensuring the reliability of data communication. Host Computer Monitoring Interface After installing the CH372 host computer driver, the CH372-based USB device can be recognized by the host computer. The system utilizes the dynamic link library CH372.d11 and its corresponding LIB file CH372.Lib and header file CH372.h provided by CH372 to establish the host computer's workflow. It calls the library functions CH375OpenDevice() and CH375CloseDevice() provided by CH372 to open and close the device, and calls CH375WriteData() and CH375ReadData() to receive data sent from the slave computer via CH372, encapsulating it into CAN format data according to the CAN bus data format. It also provides CAN data transmission and reception functions CANDownload() and CANUpload(). A corresponding graphical interface is designed in C++ to implement communication with the slave computer. In the ABSECU R & D project, we used this converter to convert the ECU's CAN data into USB data for communication with the host computer. The ECU uploads the parameters to be monitored, and the host computer downloads calibration parameters. Its hardware uses the LPC2119 with an ARM7 core as the controller, and the underlying software design ensures that the converter has good reliability in the process of transmitting a large amount of data during the actual ECU development and CCP calibration project.
Read next

CATDOLL 108CM Beth (TPE Body with Hard Silicone Head)

Height: 108cm Weight: 14.5kg Shoulder Width: 26cm Bust/Waist/Hip: 51/47/59cm Oral Depth: 3-5cm Vaginal Depth: 3-13cm An...

Articles 2026-02-22