Mikroelektronika MIKROE-724 データシート

ページ / 726
306
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
ECANxSetBaudRate
Prototype
sub procedure ECANxSetBaudRate(dim SJW, BRP, PHSEG1, PHSEG2, PROPSEG, ECAN_
CONFIG_FLAGS as word)
Description Sets ECAN module baud rate. Due to complexity of the ECAN protocol, you can not simply force the 
bps value. Instead, use this function when ECAN is in Config mode. Refer to datasheet for details.
SAM, SEG2PHTS
 and 
WAKFIL
 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.
The  ECAN  module  must  be  in  Config  mode,  otherwise  the  function  will  be  ignored.  See 
ECANxSetOperationMode.
Example
‘ set required baud rate and sampling rules
dim ecan_config_flags as word
...  
ECAN1SetOperationMode(_ECAN_MODE_CONFIG,0xFF)      ‘  set  CONFIGURATION  mode 
(ECAN1 module mast be in config mode for baud rate settings)
ecan_config_flags = _ECAN_CONFIG_SAMPLE_THRICE and ‘ Form value to be used
                  _ECAN_CONFIG_PHSEG2_PRG_ON and ‘ with ECAN1SetBaudRate
                  _ECAN_CONFIG_XTD_MSG           and
                  _ECAN_CONFIG_MATCH_MSG_TYPE    and
                  _ECAN_CONFIG_LINE_FILTER_OFF
 
 
 
 
 
 
 
 
 
 
ECAN1SetBaudRate(1, 3, 3, 3, 1, ecan_config_flags) ‘ set ECAN1 module baud rate
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.