Datasheet
CANSPIInitialize
237
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
void CANSPIInitialize( char SJW, char BRP, char PHSEG1, char
PHSEG2, char PROPSEG, char CAN_CONFIG_FLAGS);
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 Spi_Init and Spi_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.