background image

第 29 页 共 60 页

(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
frames is frames ID3

ID0, and the remaining IDs are filled with 0), and other data are sequentially converted,

as shown in Figure 3.21.

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 a CAN frame does not convert the
serial frame data completely, the same ID is still used as the frame ID of the CAN frame to continue the
conversion until the serial frame conversion is completed. The schematic diagram of data conversion is
shown in Figure 3.21. CAN frames only indicate the following useful information: frame type, frame ID, data
length and data field. In which CAN.

The "Frame Type" in the frame, the starting address and length of "Frame ID" in the serial frame are

determined by the user's configuration, and remain unchanged all the time unless the user reconfigures the
product again. 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.21 Serial frame to CAN frame (transparent

generation identification conversion, data less than or equal to

8 bytes)

Содержание TD3USPCAN

Страница 1: ...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: ...tworking 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 par...

Страница 3: ...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: ... 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 Su...

Страница 5: ...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: ... 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: ...ge 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...

Страница 8: ...h 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 TD...

Страница 9: ...第 9 页 共 60 页 Figure 2 5 TD3USPCAN SPI to CAN hardware reference circuit Figure 2 6 TD5USPCAN SPI to CAN hardware reference circuit ...

Страница 10: ...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 parameter...

Страница 11: ...s 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 networki...

Страница 12: ...on 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...

Страница 13: ...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...

Страница 14: ...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 Si...

Страница 15: ...e 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...

Страница 16: ...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 Tab...

Страница 17: ...llows 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...

Страница 18: ...r 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 ...

Страница 19: ...nversion 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 rec...

Страница 20: ...figuration 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 gre...

Страница 21: ...x88 the format of the serial frame to CAN frame is shown in Figure 3 11 Figure 3 11 Example 1 from serial frame to CAN frame transparent conversion Example 2 It is assumed that the frame type of the converted CAN frame is Extended Frame the frame ID1 and ID0 are 0x00 and 0x01 respectively and the serial frame data are 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x09 0x0A 0x0B and 0x0C Figure 3 12 Exam...

Страница 22: ...nabled that is when the CAN frame is converted into a UART frame the information of the frame type and data length of the CAN frame is expressed by a byte with a specific meaning and this byte is used as the starting byte of the UART frame and forwarded to the UART interface followed by data The information is represented by one byte in which 7 4 bits refer to the frame type 0000 represents the st...

Страница 23: ...ce 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 When the frame ID conversion is enabled the frame information conversion is enabled by default The frame type is sent first then the frame ID is sent and finally the data is sent If the user enables frame ID conversion the converted data for...

Страница 24: ...CAN frame and the converted UART frame are shown in Figure 3 16 Figure 3 16 Example of converting CAN frame to UART frame transparent conversion frame information and frame ID conversion enabled 3 CAN 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 receivi...

Страница 25: ...me information is the first byte of the byte segment followed by data After acquiring the size of the CAN receiving buffer the master can read out the N byte segments stored in the buffer by one SPI frame at a time The information is represented by one byte in which 7 4 bits represent the frame type 0000 represents the standard frame and 1000 represents the extended frame 3 0 bits represent data l...

Страница 26: ...ormation frame ID and frame data into the buffer The ID of CAN frame is stored in 2 bytes standard frame or 4 bytes extended frame The frame information byte frame ID byte and frame data byte form a byte segment and each byte segment includes the information ID and data of an independent CAN frame In which the frame information comes first followed by the frame ID the high bit of the frame ID come...

Страница 27: ...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 The n frame ID is 0x0009 and the data are 0x11 0x22 0x33 0x44 0x55 0x66 0x77 Then the CAN frame and the converted SPI frame are shown in Figure 3 20 ...

Страница 28: ...CAN frame as the frame ID of the CAN frame when the serial frame is forwarded When the CAN frame is converted into a serial frame the product converts the frame ID of the CAN frame to the corresponding position of the serial frame and returns the frame information at the same time In the mode of transparent identification conversion users CAN control the CAN frame ID of data sent by serial frames ...

Страница 29: ...l frame is less than or equal to 8 bytes the data is forwarded through a CAN frame If a CAN frame does not convert the serial frame data completely the same ID is still used as the frame ID of the CAN frame to continue the conversion until the serial frame conversion is completed The schematic diagram of data conversion is shown in Figure 3 21 CAN frames only indicate the following useful informat...

Страница 30: ...x33 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 Since the starting address in the configuration serial frame is 2 and the length is 3 three bytes are taken continuously from the second byte in the serial frame which are 0x22 0x33 and 0x44 respectively in this example When the product is converted these three bytes are ...

Страница 31: ...this mode the frame information of CAN frame is converted to the first byte of UART frame by default As shown in Figure 3 24 The information is represented by one byte in which 7 4 bits represent the frame type 0000 represents the standard frame and 1000 represents the extended frame 3 0 bits represent data length and 0000 1000 respectively represent 0 8 bits of data For example the frame informat...

Страница 32: ...e ID of the received CAN frame is 0x00112233 and the data is 0x11 0x22 0x33 0x44 0x55 0x66 0x77 and 0x88 The conversion format is shown in Figure 3 25 Frame ID3 frame ID2 and frame ID1 in the CAN frame are sequentially converted into serial frames as the 2nd 3rd and 4th bytes and the data field of the CAN frame is sequentially converted into the unfilled part of the UART frame without any modifica...

Страница 33: ...ives a CAN data frame the product simultaneously places the frame information frame ID and frame data into the buffer CAN frame information is stored as the first byte and the frame ID is stored at the specified location according to the user configured starting address and length Frame information frame ID bytes and frame data bytes form a byte segment and each byte segment includes the frame inf...

Страница 34: ...eceived by the CAN interface is a standard frame the first frame ID is 0x0122 and the data is 0x11 0x22 0x33 0x44 and 0x55 The nth frame ID is 0x0234 and the data are 0x11 0x22 0x33 0x44 0x55 0x66 and 0x77 Then the CAN frame and the converted SPI frame are shown in Figure 3 27 Frame ID1 and frame ID0 in the CAN frame are sequentially converted to the 2nd and 3rd bytes of each byte segment and the ...

Страница 35: ...the data field Frame type refers to the frame type for sending CAN frames 0x00 stands for standard frame and 0x08 stands for extended frame of paintings or calligraphy ID refers to the frame ID of sending the CAN frame When the frame type is 0x00 the frame ID consists of 2 bytes with the highest bit first When the frame type is 0x08 the frame ID consists of 4 bytes with the high bits first Data fi...

Страница 36: ... 3 28 and Figure 3 29 are schematic diagrams of serial frame to CAN frame Fig 3 28 shows that the number of bytes in the serial frame data field is less than or equal to 8 and all data are forwarded through a CAN frame Figure 3 29 The number of bytes in the serial frame data field is greater than 8 and the data is forwarded through multiple CAN frames Figure 3 28 Serial frame to CAN frame 1 custom...

Страница 37: ...ART to CAN mode the CAN bus will forward a frame as soon as it receives a CAN frame Data format correspondence is shown in Figure 3 31 During conversion the CAN frame type is converted to UART frame type byte the frame ID is converted to UART frame ID byte and all data in the CAN frame data field are sequentially converted to serial frame data field In order to ensure the integrity of the serial f...

Страница 38: ... 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 ...

Страница 39: ...acquires the size of the CAN buffer from TD5 3 USPCAN SPI CAN read out all the CAN frame data contained in the CAN buffer by one frame In the custom conversion mode the CAN receiving buffer stores a collection of bytes in multiple valid formats When the CAN terminal receives a CAN data frame it converts it into a byte segment conforming to the user defined format and places it in the buffer After ...

Страница 40: ...ersion 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 ways o...

Страница 41: ... to UART SPI the frame information of CAN frame will be converted to UART SPI at the same time See for details Section 3 3 1 4 Allows the CAN frame ID to be converted into a serial frame This configuration parameter is only valid in transparent conversion mode If it is enabled the frame information conversion will be enabled by default When CAN is converted to UART SPI the frame ID and frame infor...

Страница 42: ...hes the set value the feedback is triggered 4 1 4 CAN parameters 1 Baud rate Refers to the working baud rate of CAN The effective baud rate of CAN is shown in table 4 6 Send frame type 2 Send frame type This configuration parameter is only valid in transparent conversion and transparent conversion with identification modes Refers to the type of CAN frame sent including two types standard frame and...

Страница 43: ...e does not work and the frame identification of the corresponding bit is that any value can be received The padding data format is hexadecimal and each 8 bit byte is separated by a space character 7 Acceptance code Acceptance codes include acceptance code 0 acceptance code 5 totally 6 groups The comparison value when the CAN frame ID is accepted corresponds to the mask code according to the bit re...

Страница 44: ...Receiving filtering mode Extended frame filtering Selection of filter mode for CAN acceptance Masking code FF FF FF FF CAN acceptance filter mask code Acceptance code 0 00 00 00 00 CAN acceptance filter arbitration code 0 Acceptance code 1 00 00 00 00 CAN acceptance filter arbitration code 1 Acceptance code 2 00 00 00 00 CAN acceptance filter arbitration code 2 Acceptance code 3 00 00 00 00 CAN ac...

Страница 45: ... for transparent conversion and transparent conversion with identification Send identifier 00 00 00 00 ID3 ID0 from UART SPI to CAN Only applicable to transparent conversion The length of CAN identification in serial frame 4 bytes The length of CAN identification in serial frame Only applicable to transparent conversion with identification CAN identifies the starting address in the serial frame 0 ...

Страница 46: ...fter receiving and processing correctly TD5 3 USPCAN set the INT pin low to inform the master that the processing is completed and the response frame can be read If users don t want to test the INT pin they should wait for a certain time after the master sends the command frame After TD5 3 USPCAN processing is completed SPI master can read the response frame data or change the working state of the...

Страница 47: ...needed to configure TD5 3 USPCAN The format of the configuration command frame is shown in Table 4 4 Table 4 4 Write Configuration Command Frame Format Frame start Command word Data length Data field Check word 2 bytes 1 byte 1 byte 60 bytes 1 byte 0xF7 0xF8 0x01 0x3C As defined in Table 4 5 XOR of all previous bytes Description Frame start 2 bytes followed by 0xF7 and 0xF8 Command word 1 byte Fix...

Страница 48: ...01 0x00 Disabled 0x01 Enabled 9 Receiving filtering mode 0x08 0x00 0x08 Extended frame filtering only 0x00 Standard frame filtering only 10 13 Masking code 00 00 00 00 FF FF FF FF 14 17 Acceptance code 0 00 00 00 00 FF FF FF FF 18 21 Acceptance code 1 00 00 00 00 FF FF FF FF 22 25 reserved bytes Not used invalid 29 29 Acceptance code 2 00 00 00 00 FF FF FF FF 30 33 Acceptance code 3 00 00 00 00 FF...

Страница 49: ...led 0x01 Enabled This item is only used for transparent conversion 46 CAN frame ID is forwarded to serial frame 0x00 0x01 0x00 Disabled 0x01 Enabled This item is only used for transparent conversion 47 Send frame type 0x08 0x00 0x08 Extended frame 0x00 Standard frame This item is used for transparent conversion and transparent conversion with identification change 48 51 Send identifier 00 00 00 00...

Страница 50: ...One byte user defined 56 Feedback trigger frame number 0x08 0xFF With one CAN frame as a unit this item is only used in SPI to CAN mode 57 Feedback trigger time 0x01 0xFF With 100ms as a time unit this item is only used in SPI to CAN mode 58 CPOL 0x00 0x01 Only 0x01 is temporarily supported 59 CPHA 0x00 0x01 Only 0x01 is temporarily supported Table 4 6 Code table of serial port and CAN baud rate C...

Страница 51: ...ontrol terminal to respond The format of the configuration response frame is shown in Table 4 7 Table 4 7 Format of command frame for writing configuration parameters Frame start Command word Status word Check word 2 byte 1 byte 1 byte 1 byte 0xF7 0xF8 0x01 0x13 or 0x07 XOR of all previous bytes Description Frame start 2 bytes followed by 0xF7 and 0xF8 Command word the command word in the response...

Страница 52: ...data field within the frame which is fixed at 4 i e 0x04 Data field 4 bytes product hardware identification information Check word 1 byte which is exclusive OR of all previous bytes 2 Verify product hardware identification response frame After receiving the command frame for verifying product hardware identification TD5 3 USPCAN will identify the hardware identification in the command frame with i...

Страница 53: ... word 2 byte 1 byte 1 byte 0 byte 1 byte 0xF7 0xF8 0x03 0x00 None 0x0C Description Frame start 2 bytes followed by 0xF7 and 0xF8 Command word 1 byte Fixed at 0x03 Data length 1 byte this command frame has no data and is fixed at 0x00 Data 0 bytes no data Check word 1 byte which is the exclusive OR of all previous bytes namely 0x0C 2 Read configuration parameter response frame After receiving the c...

Страница 54: ...00bps and cannot be changed If the baud rate used is incorrect the configuration cannot be successful The configuration method is as follows 1 CFG is set low MODE is set low RST is reset wait for at least 3ms and the product enters UART configuration mode 2 Send MCU write configuration command frame product RXD receives data 3 After receiving the configuration command frame the product actively se...

Страница 55: ...SSEL high wait for at least 150ms or detect that the INT pin is low 4 CTL0 is set high CTL1 is set low and TD5 3 USPCAN is controlled to enter SPI master read state waiting for at least 50us 5 Set SSEL low the master sends 5 bytes of invalid data receives the product write configuration response frame and then sets SSEL high 6 Confirm the MCU write configuration response frame content and judge wh...

Страница 56: ...r to Section 5 Auxiliary Development Tools for detailed configuration instructions 5 Auxiliary development tools 5 1 TD5 3 USPCANCFG configuration software TDxUSPCANCFG is an auxiliary development tool specially developed for TD5 3 USPCAN series products Users can use this software to configure the product very conveniently At the same time the software provides the complete frame data of the writ...

Страница 57: ...lease the occupied serial port first and then reconnect TDxUSPCANCFG software Connect button Connect or disconnect the product with this button Configuration parameter setting interface In this area the user can set the configuration parameters of the functions that the product needs to realize The configuration parameters are divided into four categories conversion parameters SPI parameters UART ...

Страница 58: ... of the software Read Configuration button used to read the current configuration of the product and update the parameters of Configuration Parameter Setting Interface to the read values This button is used when the user needs to know the current configuration of the product Write Configuration button used to write the parameters set in Configuration Parameter Selection Interface into the product ...

Страница 59: ...d power interface using 12VDC power supply Power switch Evaluation board switch Isolated power supply Evaluation board power supply Voltage selection Product power supply option 3 3V and 5V can be selected Reset Product reset key MODE pin level Product mode switch 0 is UART mode and 1 is SPI mode CFG pin level Product configuration switch 0 is configuration mode and 1 is conversion mode 24PIN base...

Страница 60: ...PCANCFG configuration software and TD5 3 USPCAN evaluation board users can use computers to quickly configure the functions of products conveniently Next the product is configured with TD5 3 USPCANCFG and TD5 3 USPCAN evaluation boards through practical operation and the process and steps are as follows 1 Connect the power adapter 8 24V 12V recommended to the power interface 2 Use serial cable or ...

Страница 61: ...ndards If you need to know more about the electrical parameters of TD5 3 USPCAN products please refer to TD5 3 USPCAN Technical Manual 7 Disclaimer The copyright of the isolated UART SPI to CAN transceiver module TD5 3 USPCAN belongs to MORNSUN Guangzhou Science Technology Co Ltd and its property rights are absolutely protected by national laws Without the authorization of this company other compa...

Отзывы: