emCANTransmit | Top Next

emCANTransmit Transmit CAN bus frame by one channel and one sequence. Since R2019b Library: embeddedCreatorLib ( Dafulai Electronics) / Embedded CAN Bus / emCANTransmit Description Transmit CAN bus Data or Remote frame by one sequence from Channel A or Channel B or Channel C. We can transmit CAN Bus Data/Remote frame in 3 different Channels at the same time. (Of cause, you'd better configure 3 buffers for transmitting in GUI software like Microchip MCC and STM32CubeIDE). In general, you can set 3 Channels into different sample time. Inside every channels, transmitting is in serial by Sequences. Every channel has maximum 31 Sequences: Seq0 to Seq30. Seq0 is the most highest priority, Seq30 is the most lowest priority. Before you transmitting any frame, you must make sure "Channel" is in Idle state. The is guaranteed by connecting "En" input port to output port of block "isCANTx_Idle". After all sequences of one channel transmitting done (maybe timeout), you must call block "setCANTx2Idle" to set Channel to idle state. How to know Transmitting done for one Channel? Please call block "emCANChannelAllTxDone" Notes: You 'd better set up 3 CAN bus transmitting buffers if you use 3 transmission Channels in MCU Configuration software such as MPLABX IDE MCC for Microchip technology MCUs. Of cause, if you only use one or two Channels, you can setup only one or two CAN bus transmitting buffers. Parameters Please double click this block to open parameters dialog below: Let us explain parameters.
• | Peripheral CAN bus Number — tell system this block is which CAN controller peripheral used. You just choose from drop list items: 1 or 2.
• | Settings input data format — radio button to select CAN ID format is Hex or decimal. You can change this setting in any time to see CAN ID in Hex or Decimal way.
• | Transmit Channel No: — drop list to select transmission Channel A or Channel B or Channel C.
• | Transmit Sequence No:— drop list to select transmission sequence Number from Seq0 to Maximum Sequence.
• | Transmitted CAN Packet type —radio button to select transmission CAN ID type. It can be one of "Standard 11 bits CAN ID short frame", "Standard 11 bits CAN ID long frame", "Standard 29 bits CAN ID short frame" and "Standard 29 bits CAN ID long frame"
• | CAN ID for transmitted frame(s) — CAN Bus transmitting CAN ID. This is 11bits or 29 bits of scalar integer.
• | Transmit Remote Frame — tell this block whether transmitted CAN bus is remote frame.
• | Transmitted data type — It specifies data type of data field for this transmitted CAN bus data frame. It can be scalar or vector. element can be "bool","uint8", "int8","uint16","int16","uint32","int32","single". How many vector elements it has is how many data input ports it has.If data input port is vector, please follow * and vector element Qty. For example, [ int8, uint16*2, bool*7] denote that data field has 6 bytes, and block has 3 input data port. The 1st input port "Data1" is "int8" type of scalar. The 2nd input port "Data2" is "uint16" type of vector with 2 elements. The 3rd input port "Data3" is "bool" type of vector with 7 elements. Notes: We cannot put any quotation mark in vector or scalar. For example, you cannot use [ "int8", "uint16*2", "bool*7"], You cannot use " [ int8, uint16*2, bool*7]". You must use [ int8, uint16*2, bool*7].
.
• | Endian — It is bool type vector of bit order and "int16/uint16/uint32/int32/single" type of byte order. For example, Transmitted data type parameter=[bool*3 uint16]. It occupies 3 bytes. D0 denotes the 1st byte of data field. D1 denotes the 2nd byte of data field. D2 denotes the 3rd byte of data field. D0.0 denotes D0's LSb (less significant bit). D0.7 denotes D0's MSb (most significant bit). The input port "Data1" is bool type of vector with 3 elements. The input port "Data2" is uint16 type of scalar. When we use "Little-Endian", Data1=[ D0.0 D0.1 D0.2] and Data2= D2.2 D2.1 D2.0 D1.7 D1.6 D1.5 D1.4 D1.3 D1.2 D1.1 D1.0 D0.7 D0.6 D0.5 D0.4 D0.3. When we use "Big-Endian", Data1=[ D0.7 D0.6 D0.5] and Data2= D0.4 D0.3 D0.2 D0.1 D0.0 D1.7 D1.6 D1.5 D1.4 D1.3 D1.2 D1.1 D1.0 D2.7 D2.6 D2.5
• | Need response to this transmitted sequence — Logical scalar. True means that this sequence will wait for special CAN Bus frame received after this sequence's transmission done. When specified CAN Bus frame received or timeout, this sequence ends and it will start next sequence. Seq0 to Seq3 can be set to true for this parameter. The other sequences cannot be set to true for this parameter. Only when this parameter is true, has it "Data1" to "Datan" output port to denote response data.
• | Time out for response in ms — unsigned 16 bits of integer to denote timeout for transmission frame which needs response frame.
• | Response CAN Packet Type — radio button to select response CAN ID type. It can be one of "Standard 11 bits CAN ID short frame", "Standard 11 bits CAN ID long frame", "Standard 29 bits CAN ID short frame" and "Standard 29 bits CAN ID long frame"
• | CAN ID for response frame(s) — response CAN ID. This is 11bits or 29 bits of scalar integer.
• | Response data type — It specifies data type of data field for CAN bus response data frame. It can be scalar or vector. element can be "bool","uint8", "int8","uint16","int16","uint32","int32","single". How many vector elements it has is how many data output ports it has.If data output port is vector, please follow * and vector element Qty. For example, [ int8, uint16*2, bool*7] denote that data field has 6 bytes, and block has 3 output data port. The 1st output port "Data1" is "int8" type of scalar. The 2nd output port "Data2" is "uint16" type of vector with 2 elements. The 3rd output port "Data3" is "bool" type of vector with 7 elements. Notes: We cannot put any quotation mark in vector or scalar. For example, you cannot use [ "int8", "uint16*2", "bool*7"], You cannot use " [ int8, uint16*2, bool*7]". You must use [ int8, uint16*2, bool*7].
• | Sample time in sec (-1 for inherited): — Sample time for this block. It is the same meaning as general Simulink block .
Ports Input
• | En — "logical" data type's scalar. "True" means CAN bus controller will transmit. And it will make this transmission channel into "busy" state. In general, "En" connects the output port of "isCANTx_Idle" block.
For other data input ports, it depends on parameter "Transmit Remote Frame" and "Transmitted data type". When "Transmit Remote Frame" is false, parameter "Transmitted data type" vector element QTY is Input data port QTY. Please read parameter "Transmitted data type" above. and see description below
• | Data1 — vector or scalar. Parameter "Transmitted data type" vector's first element decides what data type it is. and " *digit" decides vector size
.
• | Data2 — vector or scalar. Parameter "Transmitted data type" vector's second element decides what data type it is. and " *digit" decides vector size.
• | Data3 — vector or scalar. Parameter "Transmitted data type" vector's third element decides what data type it is. and " *digit" decides vector size.
......
• | Data n — vector or scalar. Parameter "Transmitted data type" vector's number n element decides what data type it is. and " *digit" decides vector size.
Outport
• | Done — "logical" data type's scalar. "True" means CAN bus controller has done this sequence transaction. But it may successes or fails.
• | Success — "logical" data type's scalar. "True" means CAN bus controller has done this sequence transaction successfully.
For other data output ports,It depends on parameter "Need response to this transmitted sequence". When "Need response to this transmitted sequence" is true, there are data output ports as below:
• | Data1 — vector or scalar. Parameter "Response data type" vector's first element decides what data type it is. and " *digit" decides vector size
.
• | Data2 — vector or scalar. Parameter "Response data type" vector's second element decides what data type it is. and " *digit" decides vector size.
• | Data3 — vector or scalar. Parameter "Response data type" vector's third element decides what data type it is. and " *digit" decides vector size.
......
• | Data n — vector or scalar. Parameter "Response data type" vector's number n element decides what data type it is. and " *digit" decides vector size.
Examples