Datasheet
190
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
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.
Example
// CANSPI module connections
var CanSpi_CS : sbit at PORTB.B0;
CanSpi_CS_Direction : sbit at DDRB.B0;
CanSpi_Rst : sbit at PORTB.B2;
CanSpi_Rst_Direction : sbit at DDRB.B2;
// End CANSPI module connections
var Can_Init_Flags: byte;
...
Can_Init_Flags := CAN_CONFIG_SAMPLE_THRICE and // form value to
be used
CAN_CONFIG_PHSEG2_PRG_ON and // with
CANSPIInitialize
CAN_CONFIG_XTD_MSG and
CAN_CONFIG_DBL_BUFFER_ON and
CAN_CONFIG_VALID_XTD_MSG;
...
Spi_Rd_Ptr := @SPI1_Read; // Pass pointer to SPI Read func-
tion of used SPI module
SPI1_Init(); // initialize SPI module
CANSPIInitialize(1,3,3,3,1,Can_Init_Flags); // initialize
external CANSPI module