Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
249
CANxSetOperationMode
Prototype
sub procedure CANxSetOperationMode(dim mode, WAIT as word)
Description Sets the CAN module to requested mode.
Parameters -
Parameters -
mode
: CAN module operation mode. Valid values:
CAN_OP_MODE
constants. See CAN_OP_MODE
constants.
-
WAIT
: CAN mode switching verification request. If
WAIT == 0
, the call is non-blocking. The
function does not verify if the CAN module is switched to requested mode or not. Caller must use
CANxGetOperationMode to verify correct operation mode before performing mode specific operation.
If
WAIT != 0
, the call is blocking – the function won’t “return” until the requested mode is set.
Returns
Nothing.
Requires
MCU with the CAN module.
MCU must be connected to the CAN transceiver (MCP2551 or similar) which is connected to the CAN
bus.
Example
‘ set the CAN1 module into configuration mode (wait inside CAN1SetOperationMode
until this mode is set)
CAN1SetOperationMode(_CAN_MODE_CONFIG, 0xFF)
Notes
- CAN library routine require you to specify the module you want to use. To use the desired CAN
module, simply change the letter
x in the routine prototype for a number from 1 to 2.
- Number of CAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
CANxGetOperationMode
Prototype
sub function CANxGetOperationMode() as word
Description The function returns current operation mode of the CAN module. See CAN_OP_MODE constants or
device datasheet for operation mode codes.
Parameters None.
Returns
Returns
Current operation mode.
Requires
MCU with the CAN module.
MCU must be connected to the CAN transceiver (MCP2551 or similar) which is connected to the CAN
bus.
Example
‘ check whether the CAN1 module is in Normal mode and if it is then do
something.
if (CAN1GetOperationMode() = _CAN_MODE_NORMAL) then
...
end if
Notes
- CAN library routine require you to specify the module you want to use. To use the desired CAN
module, simply change the letter
x in the routine prototype for a number from 1 to 2.
- Number of CAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.