Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
303
ECANxInitialize
Prototype
sub procedure ECANxInitialize(dim SJW, BRP, PHSEG1, PHSEG2, PROPSEG, ECAN_
CONFIG_FLAGS as word)
Description Initializes the ECAN module.
The internal ECAN module is set to:
- Disable ECAN capture
- Continue ECAN operation in Idle mode
- Abort all pending transmissions
- Clear all transmit control registers
- Fcan clock : Fcy (Fosc/2)
- Baud rate is set according to given parameters
- ECAN mode is set to Normal
- Filter and mask registers remain unchanged
SAM, SEG2PHTS, WAKFIL
and
DBEN
bits are set according to the
ECAN_CONFIG_FLAGS
value.
Parameters -
SJW
as defined in MCU’s datasheet (ECAN Module)
-
BRP
as defined in MCU’s datasheet (ECAN Module)
-
PHSEG1
as defined in MCU’s datasheet (ECAN Module)
-
PHSEG2
as defined in MCU’s datasheet (ECAN Module)
-
PROPSEG
as defined in MCU’s datasheet (ECAN Module)
-
ECAN_CONFIG_FLAGS
ECAN module configuration flags. Each bit corresponds to the appropriate
ECAN module parameter. Should be formed out of predefined ECAN flag constants. See ECAN_
CONFIG_FLAGS constants.
Returns
Nothing.
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.
Example
‘ initialize the ECAN1 module with appropriate baud rate and message
acceptance flags along with the sampling rules
dim ecan_config_flags as word
...
ecan_config_flags = _ECAN_CONFIG_SAMPLE_THRICE and ‘ Form value to be used
_ECAN_CONFIG_PHSEG2_PRG_ON and ‘ with ECANInitialize
_ECAN_CONFIG_XTD_MSG and
_ECAN_CONFIG_MATCH_MSG_TYPE and
_ECAN_CONFIG_LINE_FILTER_OFF
ECAN1Initialize(1, 3, 3, 3, 1, ecan_config_flags)‘ initialize the ECAN1 module
Notes
- ECAN mode NORMAL will be set on exit.
- 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.