MORNSUN TD3USPCAN Supplement

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

第
2
页 共 60 页
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............................................................................................................................ 7
2.5 SPI to CAN hardware circuit................................................................................................................................ 8
2.6 Peripheral protection circuit..............................................................................................................................10
2.7 Recommended networking mode..................................................................................................................11
3. Product application.......................................................................................................................................................11
3.1 Noun interpretation..............................................................................................................................................11
3.2 Work pattern.......................................................................................................................................................... 12
3.2.1 UART to CAN mode.................................................................................................................................. 14
3.2.2 SPI to CAN mode...................................................................................................................................... 15
3.2.3 UART configuration mode.......................................................................................................................19
3.2.4 SPI configuration mode........................................................................................................................... 19
3.3 Data conversion mode.......................................................................................................................................19
3.3.1Transparent conversion.............................................................................................................................19
3.3.2 Transparent conversion with identification.........................................................................................28
3.3.3 Custom protocol conversion..................................................................................................................35
4. Product configuration................................................................................................................................................... 40
4.1 Configuration parameter...................................................................................................................................40
4.1.1 Conversion parameter............................................................................................................................ 40
4.1.2 UART parameters.......................................................................................................................................41
4.1.3 SPI parameters........................................................................................................................................... 42
4.1.4 CAN parameters....................................................................................................................................... 42
4.2 Factory default configuration...........................................................................................................................44

第
3
页 共 60 页
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. Auxiliary development tools........................................................................................................................................ 56
5.1 TD5(3)USPCANCFG configuration software...................................................................................................56
5.2 TD5(3)USPCAN evaluation board.....................................................................................................................58
5.3 Upper computer configuration example.......................................................................................................60
6. Notes of product using..................................................................................................................................................61
7. Disclaimer......................................................................................................................................................................... 61

第
4
页 共 60 页
1.Function introduction
1.1 Summary
TD5(3)USPCAN series isolated UART/SPI to CAN module is a communication module integrating
microprocessor, CAN transceiver, DC-DC isolated power supply and signal isolation. It has the advantages of
high speed, high isolation, low power consumption and multi-protocol conversion function. It can expand
more CAN interfaces through UART/SPI interface when the CAN control resources on the user master control
board are in short supply.
This product has various functions and is easy to embed. Users can embed in devices with UART/SPI
without changing their hardware devices, so that users can get more CAN communication interfaces and
realize convenient data communication between UART/SPI devices and CAN bus.
1.2 Product characteristics
Built-in high-efficiency isolated power supply
Isolation at both ends (3kVDC)
UART baud rate up to 921.6Kbps
SPI rate up to 1.5Mbps
CAN baud rate up to 1Mbps
Support transparent conversion, transparent conversion with identification and custom
protocol conversion.
Support bidirectional data communication between UART/SPI and CAN interface
Operating temperature range: -40℃~ +85℃
The same network can support connecting 110 nodes.
It integrates the functions of isolation and ESD bus protection
1.3 Product model
Product
Power
input
(VDC)
Level
(VDC)
UART rate
(bps)
SPI rate
(bps)
CAN rate
(bps)
Number
of nodes
Package
TD3USPCAN
3.3
3.3
300-921.6k
0-1.5M
5k-1M
110
DIP-24
TD5USPCAN
5
3.3
300-921.6k
0-1.5M
5k-1M
110
DIP-24

第
5
页 共 60 页
1.4 Applications
Charging Station
BMS
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. Product definition is shown in Figure 2.2. The pin functions are defined in Table 2.1.

第
6
页 共 60 页
Figure 2.2 Pin arrangement
Table 2.1 Pin function (defintion)
Pin
Name
Function
Pin
Name
Function
1
VCC
Input power supply
positive
12
CANH
CANH pin
2
GND
Input power ground
18
SSEL
SPI chip select pin
3
RST
Reset pin
19
CTL0
SPI master control pin 0
4
TXD
UART sending pin
20
INT
Slave feedback pin
5
RXD
UART receiving pin
21
SCK
SPI SCK pin
6
MODE
Mode control pin
22
MOSI
SPI MOSI pin
7
CTL1
SPI master control
pin 1
23
MISO
SPI MISO pin
10
CGND
Isolated output
power ground
24
CFG
Configuration pin
11
CANL
CANL pin

第
7
页 共 60 页
2.3 IO description
Table 2.2 Product Pin Description Table
Pin
Name
Type
Explain
Pin
Name
Type
Explain
1
VCC
Input
--
12
CANH
Input/Output
--
2
GND
Input
--
18
SSEL
Input
5V voltage
tolerance
3
RST
Input
Low-level reset,
supporting
open-drain input
19
CTL0
Input
5V voltage
tolerance
4
TXD
Input
--
20
INT
Output
5
RXD
Input
5V voltage tolerance
21
SCK
Input
5V voltage
tolerance
6
MODE
Input
5V voltage tolerance
22
MOSI
Input
5V voltage
tolerance
7
CTL1
Input
5V voltage tolerance
23
MISO
Output
5V voltage
tolerance
10
CGND
--
--
24
CFG
Input
5V voltage
tolerance
11
CANL
Input/Output
--
2.4 UART to CAN hardware circuit
When using the UART-to-CAN function, it is necessary to connect the MODE pin to low level. The UART of
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.

第
8
页 共 60 页
Figure 2.3 UART to CAN reference circuit (TD3USPCAN)
Figure 2.4 UART to CAN reference circuit (TD5USPCAN)
2.5 SPI to CAN hardware circuit
When using the SPI-to-CAN function, it is necessary to connect the MODE pin to the high level. The SPI
interface of MCU is connected with the SPI interface of TD5(3)USPCAN. At the same time, MCU needs to
provide the connection between 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.

第
9
页 共 60 页
Figure 2.5 TD3USPCAN SPI to CAN hardware reference circuit
Figure 2.6 TD5USPCAN SPI to CAN hardware reference circuit

第
10
页 共 60 页
2.6 Peripheral protection circuit
TD5(3)USPCAN products can be used in various CAN bus occasions, and in harsh environments (such as
high voltage, lightning surge, and other environments), we recommend add protection circuits, which can
absorb the surge that interferes with the products in harsh environments and prevent the products from
being damaged. Figure 2.7 shows recommended peripheral protection circuit. Table 2.3 shows the value of
recommended protection circuit. Please determine whether to add peripheral protection circuit according
to the actual situation.
Figure 2.7 Peripheral protection circuit
Table 2.3 Recommended Parameter Table
Components
Recommended
parameters
Components
Recommended
parameters
R3
1MΩ
R1、R2
2.7Ω/2W
C1
1nF, 2kV
D1、D2
1N4007
T1
ACM2520-301-2
P
D3
SMBJ30CA
GDT
B3D090L
TVS1
TD3USPCAN TVS tube
SMBJ5.0A

第
11
页 共 60 页
TD5USPCAN TVS tube
SMBJ6.5A
C2
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. Regardless of the length of the bus,
both ends of the bus need to be connected with terminal resistors, which can be adjusted according to the
actual wiring, and the recommended value is generally 120 ohm. Because the lowest baud rate of
TD5(3)USPCAN is 5kbps, the longest communication distance of the bus can reach 10km. Figure 2.8 shows the
schematic diagram of recommended networking.
Figure 2.8 Schematic diagram of recommended networking
3.Product application
3.1 Glossary
1. UART
UART is the abbreviation of Universal Asynchronous Receiver/Transmitter. UART is a universal serial data
bus, which can realize full-duplex serial asynchronous communication.

第
12
页 共 60 页
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.
4. Serial frame
That is, serial bus frame is the general name of SPI bus communication frame (hereinafter referred to as
SPI frame) and UART bus communication frame (hereinafter referred to as UART frame).
5. CAN frame
That is, CAN bus frame, which is the general name of standard frame and extended frame of CAN
interface.
6. Standard frame
The type of CAN frame, the frame ID of standard frame is 11 bits in total, and the range is 0x000-0x7ff.
7. Extended frame
The type of CAN frame, the frame ID of the extended frame is 29 bits in total, and the range is
0x00000000-0x1fffffff.
8. Transparent conversion
A data transmission mode of TD5 (3)USPCAN, which means that the data between UART/SPI and CAN
bus is converted and transmitted immediately without processing.
9. Transparent conversion with identification
A data transmission mode of TD5(3)USPCAN, which adds the processing of bus identification (ID) on the
basis of transparent conversion. When the serial bus is converted to the CAN bus, the ID of the serial frame
determines the ID of the CAN frame; conversely, when the CAN bus is converted to the serial bus, the ID of
the CAN frame determines the ID of the serial frame.
10. Custom protocol conversion
A data transmission mode of TD5(3)USPCAN. 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.
3.2 Working mode
After TD5(3)USPCAN is powered on, the pin level of MODE and CFG will determine that the product is in
one of four different working modes: UART to CAN mode, SPI to CAN mode, UART configuration mode and
SPI configuration mode. Table 3.1 lists the working modes of the product at different pin levels.

第
13
页 共 60 页
Table 3.1 Selection Table of TD5(3)USPCAN Working Mode
Pin level
Working mode
MODE
CFG
RST
0
1
1
UART to CAN
1
1
1
SPI to CAN
0
0
1
UART
configuration
1
0
1
SPI
configuration
X
X
0
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. It should be noted that in order to ensure the
successful reset of the product, the reset holding time is at least 100us, and after the reset, the waiting time for
the product initialization is at least 3ms, and the normal operation can only be carried out after the product
initialization is completed, as shown in Figure 3.1. Figure 3.2 is a schematic diagram of product working mode
switching.
Figure 3.1 Schematic diagram of reset timing

第
14
页 共 60 页
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. In this mode, the SPI interface is invalid, and
it will not process any data appearing in the SPI interface, nor will it return the data received by the CAN bus
to the SPI.
1. UART frame
From the moment UART receives the first data, until it waits for n characters (this parameter is set by the
user) before it receives new data, the data in this period is defined as one frame of data, and this period of
time is defined as "frame interval". Because the character time changes with the baud rate, the frame
interval time of the same number of characters is different under different baud rates. For example, the user
sets the UART frame interval to be 2 characters and the baud rate to be 9600bps. Since each character
consists of 10 bits, the interval time is 2 * 10/9600 = 2.083 ms. The first data on the bus represents the start of a
frame, and the last data before waiting for more than n characters is the last data of the frame; wait for
more than n characters and no new data appears, which means the end of a frame. UART communication
frame format is shown in Figure 3.3
Figure 3.3 UART Communication frame format diagram

第
15
页 共 60 页
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.
The SPI can send data to the CAN bus terminal and receive data received by the CAN bus terminal. At
this time, the UART interface is invalid, and it will not process any data appearing in the UART interface, nor
will it return the data received by the CAN bus to the UART.
1. SPI frame
The data between the valid and invalid SPI chip selection is defined as one frame of data. Read data
and write data frames are defined in Figure 3.4 and Figure 3.5. There should be a time interval of 40us for
reading and writing buffer data between frames, as shown in Figure 3.6.
Figure 3.4 Schematic diagram of master reading data frame
Figure 3.5 Schematic diagram of master writing data frame

第
16
页 共 60 页
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. The corresponding functions of different levels of
mastercontrol pins are shown in Table 3.2.
Table 3.2 Master Control Function in SPI Mode
CTRL0
CTRL1
Function
0
0
Inactive
0
1
master read status
1
0
master read data
1
1
master write data
The master can read the current state of the slave to obtain the number of bytes that the product can
read and write. Select the master function as the master read state, and then read out 4 bytes through SPI,
which is the status code. The status code consists of 32 bits, and the specific definition is shown in Table 3.3.
Table 3.3 Composition of status codes in SPI mode
Bit
Meaning
Symbol
Describe
0
Readable
identification
bit
read
When the CAN receiving buffer is not
empty, this bit is 1, otherwise it is 0.
12:1
Number of
readable bytes
read_bytes
Number of bytes of CAN data that the
master can read from TD5(3)USPCAN.

第
17
页 共 60 页
13
Writable
identification
bit
write
This bit is 1 when the CAN buffer is not full,
otherwise it is 0.
25:14
Number of
writable bytes
write_bytes
Number of serial bytes that the master can
write to TD5(3)USPCAN.
31:26
Reserved bit
reserved
Reserved.
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.
Figure 3.7 Status byte data structure
After obtaining these four bytes, the user should separate the corresponding bits and use them as the
judgment benchmark for subsequent processing. Example code is as follows:
read = status[0] & 0x01; // Separate out the readable identifier bits
read_bytes = ((status[0] & 0xFE) >> 1) + ((status[1] & 0x1F) << 7);// Separate out the number
readable bytes
write = (status[1] & (1 << 5)) ? 1 : 0; // Separate out the writable identifier bits
write_bytes = ((status[1] & 0xC0) >> 6) + ((status[2] & 0xFF) << 2) +((status[3] & 0x03) << 10);
// Separate out the number readable bytes
In actual use, the data in the CAN send buffer of TD5(3)USPCAN will be sent out quickly, so the
write_bytes will generally return to the maximum value.
When the master does not need to read or write TD5(3)USPCAN, the control state should be switched to
the idle state. After the state is switched through the host CTL0 and CTL1 pins, it must take at least 50us to
enable TD5(3)USPCAN to read and write. Especially, after writing, it is necessary to keep the writing state for
at least 5us to ensure that the data CAN be correctly converted to CAN bus. Figure 3.8.

第
18
页 共 60 页
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. TD5(3)USPCAN has an INT feedback pin on the hardware, which is connected with the master. When
the following two situations occur, the INT pin will change from high level to low level, informing the master to
read data (to avoid data loss, it is recommended that the master use the falling edge trigger to detect):
(1) When the number of CAN frames in the CAN buffer reaches the set trigger point
When the number of CAN frames received in the receiving buffer of the product CAN bus reaches the
trigger point, the level of the INT pin is set low, and the INT pin will not return to the high level until the buffer is
cleared. Users can query the status of TD5(3)USPCAN after obtaining the INT signal, get the number of
readable bytes, and then read the buffer CAN data.
(2) When the CAN buffer data is less than the trigger frame number and the master does not read it
within the set time.
When the CAN buffer has data but less than the trigger frame number, if the bus has not added data for
a long time and the master has not read, the data in the CAN receiving buffer may not be processed for a
long time, which leads to low real-time performance of the data. In order to solve the real-time problem of a
small amount of data, TD5(3)USPCAN has a timer inside. If the data in the CAN buffer is not read within a
certain period of time, the INT pin will be triggered to be set low to inform the master to read the data. When
TD5 (3) USPCAN receives the last frame of data, the timer starts, and the timer is reset when the master reads.

第
19
页 共 60 页
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.
3.2.4 SPI 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 SPI interface. Please refer to Section 4 for specific
configuration instructions.
3.3 Data conversion mode
The data conversion mode of TD5 (3)USPCAN refers to the basic rules of data conversion between serial
bus and CAN bus. At the same time, the product can only work in one data conversion mode. If you need to
change the data conversion mode, you need to change the configuration. When the product is configured
with a conversion mode, it acts on SPI to CAN mode and UART to CAN mode at the same time. There are
three data conversion modes of TD5(3)USPCAN: transparent conversion, transparent conversion with
identification, and custom protocol conversion.
3.3.1 Transparent conversion
Transparent conversion means that as soon as any side bus receives data, it is immediately sent to the
other side bus without any processing. In the transparent conversion mode, TD5(3)USPCAN does not need
additional data processing, which greatly improves the speed of data conversion and the utilization rate of
buffer, because TD5(3)USPCAN is also converting and sending at the same time of receiving, and the buffer
that can be received is also vacant. In the transparent conversion mode, the detailed description of data
conversion is as follows.
1. Serial frame to CAN frame conversion ( UART/SPI→CAN )
All the data of the serial frame are sequentially filled into the data field of the CAN frame. When the
product detects that there is data on the serial bus, it immediately receives and converts it. Because the
maximum data length of CAN frame is 8 bytes, when the data length of serial frame is less than or equal to 8
bytes, the data is forwarded through a CAN frame. If the data length of the serial frame is longer than 8
characters, the product starts with the first character of the serial frame, takes 8 characters at a time and
forwards them out through a CAN frame until all the data are forwarded, at which time one serial frame
data is converted into multiple CAN frame data. Schematic diagrams of data conversion are shown in Figure

第
20
页 共 60 页
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.
Figure 3.9 Schematic diagram of serial frame to CAN frame
(transparent conversion, data no more than 8 bytes)
Figure 3.10 Conversion from serial frame to CAN frame (transparent conversion, data greater than 8 bytes)
This manual suits for next models
1
Table of contents
Popular Computer Hardware manuals by other brands

BCM
BCM EBC-5612 Series Quick installation guide

Navitar
Navitar 1-62605 Dimensional drawing

Renesas
Renesas RZ/A Series Guidelines

Mobile Devices
Mobile Devices C4D-4MEUAD V6 installation guide

SINGULARITY COMPUTERS
SINGULARITY COMPUTERS PowerBoard EVGA E1 Assembly manual

Cypress Semiconductor
Cypress Semiconductor CY62157CV30 Specification sheet