MDK-ARM Keil, MDK-ARM Datasheet - Page 148

KIT REALVIEW MCU DEVELOPMENT

MDK-ARM

Manufacturer Part Number
MDK-ARM
Description
KIT REALVIEW MCU DEVELOPMENT
Manufacturer
Keil
Type
Compiler and IDEr
Datasheets

Specifications of MDK-ARM

For Use With/related Products
ARM MCUs
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
148
CAN_init() defines the bit rate of a given CAN controller. The CAN driver
supports microcontrollers with multiple CAN controllers. Each CAN controller
is referred to by a number that starts from one. These numbers map directly onto
the physical CAN controllers on the microcontroller in ascending order. Here,
CAN controller 1 runs at 500K bit/sec. Next, the CAN_rx_object() function is
used to define which message identifiers will be received into the selected CAN
controller. In the above example, we have selected CAN controller 1 to receive
message ID 33. The second parameter in the CAN_rx_object() function refers to
the message channel. We will look at this in the object buffer section later in this
chapter. You may also define whether the message ID is 11-bit (standard) or 29-
bit (extended) in length. The CAN controller will only receive messages that
have been defined with the CAN_rx_object() function. Once we have defined all
of the messages that we want to receive, the CAN controller must be placed in its
running mode by calling the CAN_start() function.
Basic Transmit and Receive
Once the CAN controller has entered running mode it is possible to send and
receive messages to and from the CAN network. The CAN message format is
held in a structure defined in
typedef struct
} CAN_msg;
To send a message define the CAN message structure. This structure reflects the
fields of the CAN message frame. In the example below, a message frame
msg_send is defined with an identifier of 33, followed by eight bytes of user-
defined data. The data length code is set to one, so that only the first data byte
will be transmitted. The message will be sent through channel 1. The frame will
start with an 11-bit identifier followed by a message frame.
CAN_msg msg_send = {
};
U32 id;
U8
U8
U8
U8
U8
33,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1,
2,
STANDARD_FORMAT,
DATA_FRAME
data [8];
len;
ch;
format;
type;
{
// message identifier
// Message data payload
// Number of bytes in the message payload
// CAN controller channel
// Standard (11-bit) ID or extended (29-bit) ID
// Data frame or remote request frame
CAN_cfg.h
.
Chapter 6. RL-CAN Introduction

Related parts for MDK-ARM