Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
CANSPIInitialize
175
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure CANSPIInitialize(dim SJW as bytedim BRP as byte,
dim PHSEG1 
as bytedim PHSEG2 as bytedim PROPSEG as bytedim
CAN_CONFIG_FLAGS 
as byte)
Returns
Nothing.
Description
Initializes the CANSPI module.
Stand-Alone CAN controller in the CANSPI module is set to: 
- Disable CAN capture 
- Continue CAN operation in Idle mode 
- Do not abort pending transmissions 
- Fcan clock: 4*Tcy (Fosc) 
- Baud rate is set according to given parameters 
- CAN mode: Normal 
- Filter and mask registers IDs are set to zero 
- Filter and mask message frame type is set according to 
CAN_CONFIG_FLAGS
value 
SAM,SEG2PHTS,WAKFIL
and 
DBEN
bits are set according to 
CAN_CONFIG_FLAGS
value.
Parameters:
SJW
as defined in CAN controller's datasheet 
BRP
as defined in CAN controller's datasheet 
PHSEG1
as defined in CAN controller's datasheet 
PHSEG2
as defined in CAN controller's datasheet 
PROPSEG
as defined in CAN controller's datasheet 
CAN_CONFIG_FLAGS
is formed from predefined constants (see CANSPI constants)
Requires
Global variables : 
CanSpi_CS
: Chip Select line 
CanSpi_Rst
: Reset line 
CanSpi_CS_Bit_Direction
: Direction of the Chip Select pin 
CanSpi_Rst_Bit_Direction
: Direction of the Reset pin 
must be defined before using this function.
The CANSPI routines are supported only by MCUs with the SPI module.
The SPI module needs to be initialized. See the SPI1_Init and
SPI1_Init_Advanced routines. 
MCU has to be properly connected to mikroElektronika's CANSPI Extra Board
or similar hardware. See connection example at the bottom of this page.