User manual
276
mikoC PRO for dsPIC
MikroElektronika
CANxSetOperationMode
Prototype
void CANxSetOperationMode(unsigned int mode, unsigned int WAIT);
Description Sets the CAN module to requested mode.
Parameters - mode: CAN module operation mode. Valid values: CAN_OP_MODE constants. See CAN_OP_
MODE constants.
- WAIT: CAN mode switching verication 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 specic
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 conguration 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
unsigned int CANxGetOperationMode();
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 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) {
...
}
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.