User manual
324
mikoC PRO for dsPIC
MikroElektronika
ECAN Library
The mikroC PRO for dsPIC30/33 and PIC24 provides a library (driver) for working with the dsPIC33FJ and pic24HJ
ECAN module.
ECAN is a very robust protocol that has error detection and signalling, self–checking and fault connement. Faulty
ECAN data and remote frames are re-transmitted automatically, similar to the Ethernet.
Data transfer rates depend on distance. For example, 1 Mbit/s can be achieved at network lengths below 40m while
250 Kbit/s can be achieved at network lengths below 250m. The greater distance the lower maximum bitrate that can
be achieved . The lowest bitrate dened by the standard is 200Kbit/s. Cables used are shielded twisted pairs.
ECAN supports two message formats:
- Standard format, with 11 identier bits, and
- Extended format, with 29 identier bits
ECAN message format and DMA RAM buffer deniton can be found in the ECan_Defs.h header le located in the
ECAN project folder. Read this le carefully and make appropriate adjustments for mcu in use. Also, if a new project
is to be created this le has to be copied, adjusted and included into the project via include pragma directive with
corresponding Search Path updating.
Important :
ECAN buffers are located in DMA RAM, so two DMA channels are used for message transfer, one for each direction
(ECAN->DMA RAM, DMA RAM->ECAN). See the ECANxDmaChannelInit routine.
Consult CAN standard about CAN bus termination resistance.
CAN library routines require you to specify the module you want to use. To select the desired CAN module, simply
change the letter x in the routine prototype for a number from 1 to 2.
Number of CAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this
library.
Library Routines
- ECANxDmaChannelInit
- ECANxSetOperationMode
- ECANxGetOperationMode
- ECANxInitialize
- ECANxSelectTxBuffers
- ECANxFilterDisable
- ECANxFilterEnable
- ECANxSetBufferSize
- ECANxSetBaudRate
- ECANxSetMask
- ECANxSetFilter
- ECANxRead
- ECANxWrite