| Contents | Index |
Embedded Coder/ Embedded Targets/ Processors/ Texas Instruments C2000/ C281x
Use the C281x enhanced Control Area Network (eCAN) Receive block to receive eCAN messages through an eCAN mailbox. The eCAN module on the DSP chip provides serial communication capability and has 32 mailboxes configurable for receive or transmit. The C281x supports eCAN data frames in standard or extended format.
The C281x eCAN Receive block has up to three output ports.
f0 outputs a function call when the block receives a new message. Connect a function call subsystem to this port.
Msg outputs the message data as a vector. The vector is always 8 bytes long. Use Data type to and is composed of elements of the data type.
len outputs the length of the eCAN message. Select Output message length to create this output.
To use the eCAN Receive block with the eCAN Pack block in the canmsglib, set Data type to CAN_MESSAGE_TYPE.

Unique number between 0 and 15 for standard or between 0 and 31 for enhanced CAN mode. It refers to a mailbox area in RAM. In standard mode, the mailbox number determines priority.
Identifier of length 11 bits for standard frame size or length 29 bits for extended frame size in decimal, binary, or hex. If in binary or hex, use bin2dec(' ') or hex2dec(' '), respectively, to convert the entry. The message identifier is associated with a receive mailbox. Only messages that match the mailbox message identifier are accepted into it.
Select Standard (11-bit identifier) or Extended (29-bit identifier).
Frequency with which the mailbox is polled to determine if a new message has been received. A new message causes a function call to be emitted from the mailbox. If you want to update the message output only when a new message arrives, then the block needs to be executed asynchronously. To execute this block asynchronously, set Sample Time to -1, check the Post interrupt when message is received box, and refer to Asynchronous Interrupt Processing for a discussion of block placement and other necessary settings.
Note For information about setting the timing parameters of the CAN module, see Configuring Timing Parameters for CAN Blocks. |
Select one of the following options:
uint8 (vector length = 8 elements)
uint16 (vector length = 4 elements)
uint32 (vector length = 2 elements)
CAN_MESSAGE_TYPE (Select this option to use the eCAN receive block with the CAN Unpack block.)
The length of the vector for the received message is at most 8 bytes. If the message is less than 8 bytes, the data buffer bytes are right-aligned in the output. The data are unpacked as follows using the data buffer, which is 8 bytes.
For uint8 data, eCAN Receive reads each unit of 8 bytes in the registers, and outputs 8-bit data to 8 elements (using the lower part of the 16-bit memory):
Output[0] = data_buffer[0]; Output[1] = data_buffer[1]; Output[2] = data_buffer[2]; Output[3] = data_buffer[3]; Output[4] = data_buffer[4]; Output[5] = data_buffer[5]; Output[6] = data_buffer[6]; Output[7] = data_buffer[7];
For uint16 data,
Output[0] = data_buffer[1..0]; Output[1] = data_buffer[3..2]; Output[2] = data_buffer[5..4]; Output[3] = data_buffer[7..6];
For uint32 data,
Output[0] = data_buffer[3..0]; Output[1] = data_buffer[7..4];
For example, if the received message has two bytes:
data_buffer[0] = 0x21 data_buffer[1] = 0x43
The uint16 output would be:
Output[0] = 0x4321 Output[1] = 0x0000 Output[2] = 0x0000 Output[3] = 0x0000
When you select CAN_MESSAGE_TYPE, the block outputs the following struct data (defined in can_message.h):
struct {
/* Is Extended frame */
uint8_T Extended;
/* Length */
uint8_T Length;
/* RTR */
uint8_T Remote;
/* Error */
uint8_T Error;
/* CAN ID */
uint32_T ID;
/*
TIMESTAMP_NOT_REQUIRED is a macro that will be defined by Target teams
PIL, xPC if they do not require the timestamp field during code
generation. By default, timestamp is defined. If the targets do not require
the timestamp field, they should define the macro TIMESTAMP_NOT_REQUIRED before
including this header file for code generation.
*/
#ifndef TIMESTAMP_NOT_REQUIRED
/* Timestamp */
double Timestamp;
#endif
/* Data field */
uint8_T Data[8];
};
Select to output the message length in bytes to the third output port. If not selected, the block has only two output ports.
Select this check box to post an asynchronous interrupt when a message is received.
Select the interrupt line the asynchronous interrupt uses. This action sets bit 2 (GIL) in the Global Interrupt Mask Register (CANGIM):
1 maps the global interrupts to the ECAN1INT line.
0 maps the global interrupts to the ECAN0INT line.
For detailed information on the eCAN module, see TMS320F28x DSP Enhanced Control Area Network (eCAN) Reference Guide, Literature Number SPRU074A, available at the Texas Instruments Web site.

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |