Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
309
ECANxRead
Prototype
sub function ECANxRead(dim byref id as longint, dim byref data as byte[8],
dim byref dataLen as word, dim byref ECAN_RX_MSG_FLAGS as word) as word
Description If at least one full Receive Buffer is found, it will be processed in the following way:
- Message ID is retrieved and stored to location pointed by the
id
pointer
- Message data is retrieved and stored to array pointed by the
data
pointer
- Message length is retrieved and stored to location pointed by the
dataLen
pointer
- Message flags are retrieved and stored to location pointed by the
ECAN_RX_MSG_FLAGS
pointer
Parameters -
id
: message identifier address
-
data
: an array of bytes up to 8 bytes in length
-
dataLen
: data length address
-
ECAN_RX_MSG_FLAGS
: message flags address. For message receive flags format refer to the
ECAN_RX_MSG_FLAGS
constants. See ECAN_RX_MSG_FLAGS constants.
Returns
-
0
if none of Receive Buffers is full
-
0xFFFF
if at least one of Receive Buffers is full (message received)
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 receiving is possible. See ECANxSetOperationMode.
Example
‘ check the ECAN1 module for received messages. If any was received do
something.
dim msg_rcvd, rx_flags, data_len as word
data as byte[8]
msg_id as longint
...
ECAN1SetOperationMode(_ECAN_MODE_NORMAL,0xFF) ‘ set NORMAL mode (ECAN1
module must be in a mode in which receiving is possible)
...
rx_flags = 0 ‘ clear message flags
if (msg_rcvd = ECAN1Read(msg_id, data, data_len, rx_flags)) then
...
end if
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.