Advertisement

Quick Links

Application Notes of TD5(3)USPCAN
Project
Content
Product
CAN controller, isolated transmission, signal
function
conversion, protocol conversion and port expansion
Summary
Application description and detailed
of notes
explanation of functions
第 1 页 共 60 页

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TD3USPCAN and is the answer not in the manual?

Questions and answers

Summary of Contents for MORNSUN TD3USPCAN

  • Page 1 Application Notes of TD5(3)USPCAN Project Content Product CAN controller, isolated transmission, signal function conversion, protocol conversion and port expansion Summary Application description and detailed of notes explanation of functions 第 1 页 共 60 页...
  • Page 2: Table Of Contents

    Catalogue 1. Function introduction ............................... 4 1.1 Summary ................................... 4 1.2 Product characteristics ............................4 1.3 Product model ................................ 4 1.4 Applications ................................5 2. Hardware description ..............................5 2.1 Product appearance ............................5 2.2 Pin definition ................................5 2.3 IO description ................................7 2.4 UART to CAN hardware circuit ..........................
  • Page 3 4.3 Configure communication protocol ....................... 46 4.3.1 Write configuration parameters ......................47 4.3.2 Verify product hardware identification ....................51 4.3.3 Read configuration parameters ......................53 4.4 Collocation method ............................54 4.4.1 MCU configuration mode ........................54 4.4.2 Configuration mode of upper computer ................... 56 5.
  • Page 4: Function Introduction

    It integrates the functions of isolation and ESD bus protection  1.3 Product model Power Level UART rate SPI rate CAN rate Number input Product Package of nodes (VDC) (bps) (bps) (bps) (VDC) TD3USPCAN 300-921.6k 0-1.5M 5k-1M DIP-24 TD5USPCAN 300-921.6k 0-1.5M 5k-1M DIP-24 第 4 页 共 60 页...
  • Page 5: Applications

    1.4 Applications Charging Station   Communication  Coal mining industry  Electrical industry  Instrument  Smart homes  2. Hardware description 2.1 Product appearance The appearance of the product is shown in Figure 2.1. Figure 2.1 product appearance drawing (TD5USPCAN) 2.2 Pin definition TD5(3)USPCAN has three communication interfaces, namely SPI interface, UART interface and CAN interface.
  • Page 6 Figure 2.2 Pin arrangement Table 2.1 Pin function (defintion) Name Function Name Function Input power supply CANH CANH pin positive Input power ground SSEL SPI chip select pin Reset pin CTL0 SPI master control pin 0 UART sending pin Slave feedback pin UART receiving pin SPI SCK pin MODE...
  • Page 7: Io Description

    MCU is connected to the UART interface of TD5(3)USPCAN, and a GPIO is connected to the RST pin. If you need to configure TD5(3)USPCAN through MCU, you need to connect additional GPIO to the CFG pin. Figure 2.3 and Figure 2.4 are the reference circuits of TD3USPCAN and TD5USPCAN respectively. 第 7 页 共 60 页...
  • Page 8: Spi To Can Hardware Circuit

    GPIO and RST, INT, CTL0, CTL1 pins to realize the effective monitoring and control of TD5(3)USPCAN. If TD5(3)USPCAN needs to be configured by MCU, additional GPIO is needed to connect with the CFG pin. Figure 2.5 and Figure 2.6 are the reference circuits of TD3USPCAN and TD5USPCAN respectively.
  • Page 9 Figure 2.5 TD3USPCAN SPI to CAN hardware reference circuit Figure 2.6 TD5USPCAN SPI to CAN hardware reference circuit 第 9 页 共 60 页...
  • Page 10: Peripheral Protection Circuit

    Figure 2.7 Peripheral protection circuit Table 2.3 Recommended Parameter Table Recommended Recommended Components Components parameters parameters 1MΩ R1、R2 2.7Ω/2W 1nF, 2kV D1、D2 1N4007 ACM2520-301-2 SMBJ30CA TD3USPCAN TVS tube B3D090L TVS1 SMBJ5.0A 第 10 页 共 60 页...
  • Page 11: Recommended Networking Mode

    TD5USPCAN TVS tube SMBJ6.5A 10uF, 25V Rterminal 120Ω 2.7 Recommended networking mode CAN bus generally uses linear wiring, and the number of bus nodes can reach 110. Shielded twisted pair is recommended for wiring, CANH and CANL are connected with twisted pair core, CGND is connected with the shielding layer, and finally shielding layer is grounded at a single point.
  • Page 12: Work Pattern

    2. SPI SPI is the abbreviation of Serial Peripheral Interface. SPI is a high-speed, full-duplex and synchronous communication bus. 3. CAN bus CAN is the abbreviation of Controller Area Network. CAN bus is field bus, it is a serial communication network that effectively supports distributed control or real-time monitoring.
  • Page 13 Table 3.1 Selection Table of TD5(3)USPCAN Working Mode Pin level Working mode MODE UART to CAN SPI to CAN UART configuration configuration reset If it is necessary to switch the working mode of the product, after changing the pin level, the product must be reset before it can enter the set working mode.
  • Page 14: Uart To Can Mode

    Figure 3.2 Schematic diagram of working mode switching 3.2.1 UART to CAN mode In this mode, TD5(3)USPCAN can only send or receive data to CAN bus through UART. UART communication format is fixed as: 1 start bit, 8 data bits and 1 stop bit, which cannot be changed. Communication rate of UART ranges from 300 bps to 921600 bps.
  • Page 15: Spi To Can Mode

    3.2.2 SPI to CAN mode In this working mode, TD5(3)USPCAN always acts as SPI slave, SPI is limited to work in mode 3(CPOL and CPHA are both 1), the data length is limited to 8 bits, and the MSB bits are transmitted first. Highest communication rate under transparent conversion and transparent conversion with identification is 1.5Mbps, and the highest communication rate of custom protocol conversion is 1Mbps.
  • Page 16 Figure 3.6 Schematic diagram of SPI frame interval 2. Master control TD5(3)USPCAN has two SPI Master control pins CTL0 and CTL1, which are controlled by the master. By controlling the CTL0 and CTL1 pins, the master make TD5(3)USPCAN enter different functional states, and achieve different operation purposes for TD5(3)USPCAN.
  • Page 17 Writable This bit is 1 when the CAN buffer is not full, identification write otherwise it is 0. Number of Number of serial bytes that the master can 25:14 write_bytes writable bytes write to TD5(3)USPCAN. Reserved. 31:26 reserved Reserved bit If the status[] array is defined as an 8-bit integer, and the data sequentially read out through SPI reading status are status[0], status[1], status[2] and status[3], its data structure is shown in Figure 3.7.
  • Page 18 Figure 3.8 Schematic diagram of switching delay of host control function 3. Feedback mechanism TD5(3)USPCAN only be used as an SPI slave, and can't actively control other SPI bus devices. If TD5(3)USPCAN needs the master to check the status every time it receives the data sent by CAN, the efficiency of the whole communication process will be very low, so we have added a feedback mechanism for it.
  • Page 19: Uart Configuration Mode

    3.2.3 UART configuration mode In this mode, TD5(3)USPCAN is in the waiting configuration state and cannot send or receive data to the CAN terminal. This mode can only be configured through UART interface. Please refer to Section 4 for specific configuration instructions.
  • Page 20 3.9 and Figure 3.10. CAN frames only indicate the following useful information: frame type, frame ID, data length and data field. The "Frame Type" and "Frame ID" in the CAN frame are determined by the user's configuration and remain unchanged all the time unless the user reconfigures the product. The "data length" in the CAN frame is determined according to the actual number of bytes of data allocated to the CAN frame.
  • Page 21 Conversion instance: Example 1: Assuming that the frame type of the converted CAN frame is "Standard Frame", the frame ID1 and ID0 are "0x00 and 0x01" respectively, and the data of the serial frame is 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 and 0x88, the format of the serial frame to CAN frame is shown in Figure 3.11.
  • Page 22 2. CAN frame UART frame conversion( CAN→UART ) TD5(3)USPCAN immediately forwards a frame of data from CAN bus to UART interface. During conversion, the product will convert all the data in the CAN frame data field into UART frames in sequence, and each CAN frame data will be converted into one UART frame data.
  • Page 23 Figure 3.14 CAN frame to UART frame (transparent conversion, frame information enabled) (2) Frame ID conversion enable The frame ID is the "ID" of the CAN frame. The frame conversion is enabled, that is, when the CAN frame is converted into UART frame, the ID of the CAN frame is forwarded to the UART interface in 2 bytes (standard frame) or 4 bytes (extended frame) at the same time, and the ID byte is sent before the data byte, with the high bit of the ID byte in front.
  • Page 24 If the data length of CAN frame is 0, when the frame type or frame ID needs to be converted, the corresponding conversion will be made, but the data field is empty. If there is no need to convert the frame type or frame ID, no conversion will be done.
  • Page 25 Figure 3.17 CAN frame to SPI frame (transparent conversion) (1) Frame information conversion enable Frame information refers to the "frame type" and "data length" information of CAN frame, with the length of one byte. When frame conversion is enabled, the data in CAN receiving buffer is a collection of frame information and frame data.
  • Page 26 Figure 3.18 CAN frame to SPI frame (transparent conversion, frame information conversion enabled) (2) Frame ID conversion enable The frame ID is the "ID" of the CAN frame. In SPI to CAN mode, it is considered that one SPI frame data is a collection of multiple CAN frame data most of the time.
  • Page 27 Figure 3.19 CAN frame to SPI frame (transparent conversion, frame ID conversion enabled) Conversion instance: Example 1: Assume that the user configuration is as follows: frame information conversion is enabled and frame ID conversion is enabled. If the CAN frame received by the CAN interface is a standard frame, the first frame ID is 0x0001 and the data is 0x11, 0x22, 0x33, 0x44 and 0x55;...
  • Page 28: Transparent Conversion With Identification

    Figure. 3.20 Example 1 CAN frame to SPI frame (transparent conversion, frame information, frame ID enabled) 3.3.2 Transparent conversion with identification Transparent conversion with identification is derived from transparent conversion, which means that the serial frames sent or received contain valid CAN frame ID bytes. In this way, the "frame ID" in the serial frame is automatically converted into the frame ID in the CAN frame.
  • Page 29 (standard frame) or 1 to 4 (extended frame), respectively. If the start address is set to 1 and the length is 2, the 1st and 2nd bytes in the serial frame (counting from 0) will be the CAN frame ID. During the conversion, according to the user's configuration information, all the frame ID correspondences of CAN frames in serial frames are converted into the frame ID field of CAN frames (if the number of ID bytes is less than the number of frame ID bytes of CAN frames, then the filling sequence of CAN...
  • Page 30 Figure 3.22 Serial frame to CAN frame (transparent conversion with identification , data greater than 8 bytes) Conversion instance: Since the configured CAN frame is an extenExample 1: Assume that the user configures the frame type of the converted CAN frame as "Extended Frame", the starting address of "Frame ID" in the serial frame is 2 and the length is 3, and the data sent by the serial frame is 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA and 0xBB respectively ded frame, the frame ID in the serial frame to CAN frame is 4 bytes.
  • Page 31 Figure 3.23 Example of serial frame to CAN frame 2. CAN frame to UART frame conversion (CAN→UART ) For CAN frames, it is also to forward a frame to the UART interface immediately after receiving a frame. When forwarding each time, the ID in the received CAN frame is correspondingly converted according to the position and length of the CAN frame ID configured by the user in the UART frame, and other data are forwarded in sequence.
  • Page 32 Figure 3.24 CAN frame to UART frame (transparent conversion with identification) Conversion instance: Example 1: Assume that the user configures the frame type of the converted CAN frame as "Extended Frame", and the starting address of "Frame ID" in UART frame is 2 and the length is 3. The frame ID of the received CAN frame is 0x00112233, and the data is 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 and 0x88.
  • Page 33 3. CAN frame to SPI frame conversion( CAN→SPI ) TD5(3)USPCAN, as an SPI slave, can't actively control SPI peripherals. When the product receives a frame of data from the CAN bus, it can only be stored in the CAN receiving buffer immediately. When the number of CAN frames in the CAN buffer reaches the feedback trigger frame number or trigger time, the INT pin outputs a low level to inform the SPI master to read data.
  • Page 34 Figure. 3.26 CAN frame to SPI frame (transparent conversion with identification) Conversion instance: Example 1: It is assumed that the frame type of the CAN frame converted from user configuration is "Standard Frame", and the starting address of "Frame ID" in SPI frame is 1 and the length is 2. If the CAN frame received by the CAN interface is a standard frame, the first frame ID is 0x0122 and the data is 0x11, 0x22, 0x33, 0x44 and 0x55;...
  • Page 35: Custom Protocol Conversion

    Figure 3.27 Example CAN frame to SPI frame (transparent conversion with identification) 3.3.3 Custom protocol conversion Under the custom protocol conversion mode, the serial frame must conform to the specified frame format. The valid serial frame consists of frame header, frame length, frame type, frame ID, data field and frame trailer of paintings or calligraphy.
  • Page 36 1. Serial frame to CAN frame conversion( UART/SPI→CAN ) After the serial interface receives a valid serial frame, "Frame Type" determines the frame type of the CAN frame to be sent, "Frame ID" is used as the CAN frame ID, and "Data Field" is filled into the CAN frame data field.
  • Page 37 Conversion instance: Example 1: Assume that the serial frame header configured by the user is 0x40 and the frame trailer is 0x1A. The user sends a standard frame (0x00), the frame ID is 0123, the data is 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, and the frame length is 0x0E.
  • Page 38 Figure 3.31 CAN frame to UART frame (custom protocol conversion) Conversion instance: Example 1: Assume that the serial frame header configured by the user is 0x40 and the frame trailer is 0x1A. Example of conversion is shown in Figure 3.32. Figure 3.32 Example of Can frame to UART frame (custom conversion) 第...
  • Page 39 3. CAN frame to SPI frame conversion( CAN→SPI ) TD5(3)USPCAN, as an SPI slave, can't actively control SPI peripherals. When the product receives a frame of data from the CAN bus, it can only be stored in the CAN receiving buffer immediately. When the number of CAN frames in the CAN buffer reaches the feedback trigger frame number or trigger time, the INT pin outputs a low level to inform the SPI master to read the data.
  • Page 40: Product Configuration

    Conversion instance: Example 1: Assume that the serial frame header configured by the user is 0x40 and the frame trailer is 0x1A. Example of conversion is shown in Figure 3.34. Figure 3.34 Example of Can frame to SPI frame (custom protocol conversion) 4.
  • Page 41: Uart Parameters

    receives data, it is immediately sent to the other side bus without any processing. See section 3.3.1 for a detailed description of this method. Transparent conversion with identification is derived from transparent conversion, which means that the serial frames sent or received contain valid CAN frame ID bytes. See section 3.3.2 for a detailed description of this method.
  • Page 42: Spi Parameters

    4.1.3 SPI parameters 1. Feedback trigger frame number This configuration parameter is only valid in SPI to CAN mode. TD5(3)USPCAN, as an SPI slave, can't actively send data to the host, so when TD5(3)USPCAN receives a certain amount of can frame data, it needs to inform the master to get the data through the INT pin.
  • Page 43 5. Receiving filtering mode This option is divided into extended frame filtering and standard frame filtering. If you only want to receive CAN frames in extended frame format, you should choose extended frame filtering. If you only want to receive CAN frames in standard frame format, you should choose standard frame filtering. 6.
  • Page 44: Factory Default Configuration

    4.2 Factory default configuration Table 4.2 Factory Default Configuration Parameters Parameter Default Explain Remarks Serial port operating baud UART baud rate 115200 bps rate UART data bits Serial data bit, fixed at 8 Serial port stop bit, fixed to 1 UART stop bit Unable to change Serial check bit, fixed at 0...
  • Page 45 Change Two-way Data conversion mode direction UART frame UART frame time interval 2 characters interval characters frame Forwarding enable of CAN Only applicable to information Disable frame information when transparent forwarded converting to serial frame conversion. serial frame. forwarding Forwarding enable of frame Only applicable to of CAN frame ID Disable...
  • Page 46: Configure Communication Protocol

    SPI data length is fixed at 8 Data bit length 8 bits bits. transmission Bit transmission is high mode priority. SPI working mode parameter CPOL (fixed at CPOL Unable to change SPI working mode parameter CPHA (fixed at CPHA 4.3 Configure communication protocol To configure TD5(3)USPPAN, it is necessary to reset the product and enter "SPI configuration mode"...
  • Page 47: Write Configuration Parameters

    1. Command frame The command frame is sent from the main control terminal (host computer, MCU, etc.) to the controlled terminal TD5(3)USPCAN, and the TD5(3)USPCAN performs corresponding operation after receiving the command frame. 2. Response frame The response frame refers to the response information returned by TD5(3)USPCAN to the main control terminal after TD5(3)USPCAN receives the command frame.
  • Page 48 UART data bit 0x08 Fixed at 8 UART stop bit 0x01 Fixed at 1 UART parity bit 0x00 Fixed at 0 CAN baud rate 0x00~0x0F The correspondence is shown in Table 4.6. (reserved bytes) Not used, invalid. (reserved bytes) Not used, invalid. (reserved bytes) Not used, invalid.
  • Page 49 0x01: transparent conversion; Conversion 0x02: transparent conversion 0x01~0x03 mode with identification. 0x03: Custom protocol conversion. 0x00: bidirectional; 0x00~0x02 Change 0x01: only UART/SPI to CAN;; direction 0x02: only CAN to UART/SPI. UART frame x02~0x0A interval CAN frame 0x00: Disabled; information is 0x01: Enabled.
  • Page 50 The length of In bytes, this item is only used for transparent conversion with 0x01~0x04 identification in identification. serial frame CAN identifies In bytes, this item is only used for the starting transparent conversion with 0x00~0x07 address in the identification. serial frame frame header 0x00~0xFF...
  • Page 51: Verify Product Hardware Identification

    0x07 4800 100K 0x08 2400 125K 0x09 1200 200K 0x0A 250K 0x0B 400K 0x0C 128000 500K 0x0D 230400 666K 0x0E 256000 800K 0x0F 460800 0x10 921600 2. Write configuration response frame After receiving the command frame for writing configuration parameters, TD5(3)USPCAN will update the current configuration according to the received data.
  • Page 52 Verify the product hardware identification, which is used to confirm whether the specific hardware information of the configured product is correct before configuring the product. The format of the product hardware identification command frame is shown in Table 4.8. Table 4.8 Verify the Frame Format of Product Hardware Identification Command Frame Command Data...
  • Page 53: Read Configuration Parameters

    Command word: the command word in the response frame is the same as that in the command frame, that is, 0x02. Status word: 1 byte, 0x13 indicates successful identification matching, 0x07 indicates failed identification matching. Check word: 1 byte, which is exclusive OR of all previous bytes. 4.3.3 Read configuration parameters 1.
  • Page 54: Collocation Method

    Description: Frame start: 2 bytes, followed by 0xF7 and 0xF8. Command word: the command word in the response frame is the same as that in the command frame, namely 0x03. Data length: 1 byte, the number of data bytes in the data field in the frame, fixed at 60 (i.e. 0x3C). Data field: 60 bytes, when the parameter information is configured.
  • Page 55 Figure 4.1 Timing diagram of configuration command written by UART 2.With SIP configuration When the user uses the SPI interface of MCU to connect with TD5(3)USPCAN, the product parameters can be configured through the SPI interface. Refer to Figure 2.3 and Figure 2.4 for the hardware connection diagram.
  • Page 56: Configuration Mode Of Upper Computer

    Figure 4.2 Timing diagram of configuration command written through SPI 4.4.2 Configuration mode of upper computer If users don't want to configure TD5(3)USPCAN through MCU, they can use the upper computer configuration method to configure the product first, and then use it after the configuration is completed. For configuration through the upper computer, TD5(3)USPCAN configuration software and TD5(3)USPCAN evaluation board are needed.
  • Page 57 Figure 5.1 TDxUSPCANCFG software main page Download link of PC: https://www.mornsun.cn/html/support/8/profiles.html Note: After the official website is updated, the link of the upper computer may change, and the upper computer can also be obtained from Jinshengyang official website through "official website → application support →...
  • Page 58: Td5(3)Uspcan Evaluation Board

    While "Allow CAN frame information to be converted into serial frames" is a "transparent conversion" parameter, which is only valid under "transparent conversion". Write configuration command display area  This area displays the complete frame data of the corresponding write configuration command frame under the current parameters of the Configuration Parameter Setting Interface.
  • Page 59 MODE Pin level Voltage selection Reset Power Interface CFG Pin level Switch ISP Switch Isolated Power 24PIN Base UART Interface SPI Interface USB Port CAN Interface COM Port CAN interface2 Figure 5.2 Physical drawing of TD5(3)USPCAN evaluation board Table 5.1 Explanation of interface of TD5(3)USPCAN evaluation board Location Explain Evaluation board power interface, using...
  • Page 60: Upper Computer Configuration Example

    (2) Use serial cable (or USB-to-serial cable) to connect the COM port of TD5(3)USPCAN evaluation board and the computer com port (USB port); (3) Select the correct working voltage of the product (TD5USPANA 5v, TD3USPCAN : 3.3v); (4) Place the product;...
  • Page 61: Notes Of Product Using

    TD5USPCAN standard 5V power supply, TD3USPCAN standard 3.3V power supply. TD5USPCAN and TD3USPCAN non-CAN bus signal interfaces are all 3.3V level standards.If you need to know more about the electrical parameters of TD5(3)USPCAN products, please refer to TD5(3)USPCAN Technical Manual.

This manual is also suitable for:

Td5uspcan

Table of Contents