|
emCANReadRxFrame
Read embedded CAN bus receiver Data.
Since R2019b
Library: embeddedCreatorLib ( Dafulai Electronics) / Embedded CAN Bus / emCANReadRxFrame

Description
Read CAN bus received Data or Remote frame.
For data frame, it will keep previous reading data if CAN bus controller didn't receive Data packets.
For remote frame, it will output "true" if CAN bus controller receives remote frame. And after this time's reading, it will output "false" if CAN bus controller won't receive remote frame in next sample time.
Notes: You must set up CAN bus receiver interrupt enable in MCU Configuration software such as MPLABX IDE MCC for Microchip technology MCUs.
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. |
| • | Received CAN Packet type — radio button to select received 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 received frame(s) — CAN Bus receiver's CAN ID. You just choose from drop list items. These drop list items are from "emCANSetup" block. If your received CAN ID is not in drop list, please modify "emCANSetup" block. |
| • | Remote Frame — tell this block whether received CAN bus is remote frame. If true, output port will be logical type of scalar "RTR". |
| • | Data type — It specifies data type of data field for this received CAN ID 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 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 port. The 1st output port is "int8" type of scalar. The 2nd output port is "uint16" type of vector with 2 elements. The 3rd output port 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, 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 output port1 "Data1" is bool type of vector with 3 elements. The output port2 "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 |
| • | Sample time in sec (-1 for inherited): — Sample time for this block. It is the same meaning as general Simulink block . |
Ports
Input
None
Outport
It depends on parameter "Remote Frame" and "Data type".
When "Remote Frame" is true, there is one output port as below:
| • | RTR — "logical" data type's scalar. "True" means CAN bus controller received "Remote request frame". And it will become false after next sample time if no more new remote frame received. |
When "Remote Frame" is false, parameter "Data type" vector element QTY is Output port QTY. Please read parameter "Data type" above. and see description below:
| • | Data1 — vector or scalar. Parameter "Data type" vector's first element decides what data type it is. and " *digit" decides vector size |
.
| • | Data2 — vector or scalar. Parameter "Data type" vector's second element decides what data type it is. and " *digit" decides vector size. |
| • | Data3 — vector or scalar. Parameter "Data type" vector's third element decides what data type it is. and " *digit" decides vector size. |
......
| • | Data n — vector or scalar. Parameter "Data type" vector's number n element decides what data type it is. and " *digit" decides vector size. |
Examples
|