Mikroelektronika MIKROE-724 データシート
310
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
ECANxWrite
Prototype
sub function ECANxWrite(dim id as longint, dim byref Data as byte[8], dim
DataLen, ECAN_TX_MSG_FLAGS as word) as word
Description If at least one empty Transmit Buffer is found, the function sends message in the queue for
transmission.
Parameters -
id
: ECAN message identifier. Valid values: all 11 or 29 bit values, depending on message type
(standard or extended)
-
Data
: data to be sent
-
DataLen
: data length. Valid values:
0..8
-
ECAN_TX_MSG_FLAGS
: message flags. Valid values:
ECAN_TX_MSG_FLAGS
constants. See ECAN_
TX_MSG_FLAGS constants.
Returns
-
0
if all Transmit Buffers are busy
-
0xFFFF
if at least one Transmit Buffer is empty and available for transmition
Requires
The ECAN routines are supported only by MCUs with the ECAN module.
Microcontroller must be connected to ECAN transceiver which is connected to the ECAN bus.
The ECAN module must be in a mode in which transmission is possible. See
ECANxSetOperationMode.
Example
‘ send message extended ECAN message with appropriate ID and data
dim tx_flags as word
data as byte[8]
msg_id as longint
...
ECAN1SetOperationMode(_ECAN_MODE_NORMAL,0xFF) ‘ set NORMAL mode (ECAN1
must be in a mode in which transmission is possible)
tx_flags = _ECAN_TX_PRIORITY_0 and
_ECAN_TX_XTD_FRAME and
_ECAN_TX_NO_RTR_FRAME ‘ set message flags
ECAN1Write(msg_id, data, 1, tx_flags)
Notes
- ECAN library routine require you to specify the module you want to use. To select the desired ECAN
module, simply change the letter
x in the routine prototype for a number from 1 to 2.
- Number of ECAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.