📄 readme.txt
字号:
Readme File for Code Example:
Crosswire Communication between ECAN 1 and ECAN 2 modules
---------------------------------------------------------
This file contains the following sections:
1. Hardware Requirements
2. Code Example Description
3. Folder Contents
4. Suggested Development Resources
5. Reconfiguring the project for a different dsPIC33F device
6. Revision History
1. Hardware Requirement:
----------------------------
The following boards are used for developing this code example
Explorer 16 Development Board
ECAN PicTail Card
The device used is dsPIC33FJ256GP710
Connections to be done on the ECANPicTail Card - The Tx line of ECAN1 is connected to the Rx line of ECAN2
and the Tx line of ECAN2 is connected to the Rx line of ECAN1.
Alternatively a simple 2 node (ECAN1 and ECAN2) CAN BUS can be implemented using a twisted wire pair. This twisted wire pair must be connected at the output of the transcievers. Jumpers J7 and J6 must be set.
MPLLAB ICD2 Debugger/Programmer is used for debugging and running this code example.
2. Code Example Description:
----------------------------------------------------------------------------------------------------------------
Crosswire Communication between ECAN 1 and ECAN 2 modules
4 Message Buffers are defined for ECAN1 and ECAN2
Two message buffers are configured for ECAN1. One is configured as a Transmit Buffer to generate a Data Frame.
The other is configured as a Receive Buffer to receive message sent by ECAN2.
Two message buffers are configured for ECAN2. One is configured as a Transmit Buffer to generate a Data Frame.
The other is configured as a Receive Buffer to receive message sent by ECAN1.
Filters and Masks are enabled for both ECAN1 and ECAN2 for Message Reception
----------------------------------------------------------------------------------------------------------------
In this code example, the ECAN1 and ECAN2 modules are configured for operation at 1 Mbps over the CAN bus.
This is done in the main.c file.
The configuration of the two ECAN modules is done in the ECAN1Config.c and ECAN2Config.c files.
The number of message buffers to be allocated in DMA RAM are configured by using the following definitions
in the ECAN1Config.h and ECAN2Config.h file.
#define ECAN1_MSG_BUF_LENGTH
#define ECAN2_MSG_BUF_LENGTH
The aligment attribute is used to make sure that the DMA allocates the base address for the peripheral
correctly and assigns an offset based on this base address. This is essential when using peripheral indirect
addressing mode of DMA, where the effective address is computed based on the base address partially and an
address generated by the peripheral. (in this case ECAN).
__attribute__((space(dma),aligned(Number of bytes)));
The number of bytes may be decided based on the number of buffers being configured by the definition made earlier.
This is calculated as follows -
Number of bytes = (ECAN1_MSG_BUF_LENGTH * Number of words in one buffer)*2 and
Number of bytes = (ECAN2_MSG_BUF_LENGTH * Number of words in one buffer)*2.
For eg : If 4 message buffers are defined as
#define ECAN1_MSG_BUF_LENGTH 4, then,
Number of bytes = 4 * 8 * 2 = 64 (because Number of words in one buffer = 8 for ECAN).
The information on transmit message identifiers and other bits are written as arguments into these functions
ecan1TransmitMsg(unsigned int buf, long txIdentifier, unsigned int ide, unsigned int remoteTransmit, unsigned int srr, unsigned int dataLength );
ecan1TxData(unsigned int buf, unsigned int data1, unsigned int data2, unsigned int data3, unsigned int data4);
ecan2TransmitMsg(unsigned int buf, long txIdentifier, unsigned int ide, unsigned int remoteTransmit, unsigned int srr, unsigned int dataLength );
ecan2TxData(unsigned int buf, unsigned int data1, unsigned int data2, unsigned int data3, unsigned int data4);
The information on message acceptance filters and masks are written as arguments into these function
ecan1Filter(int n, long identifier, unsigned int exide,unsigned int bufPnt,unsigned int maskSel);
ecan1Mask(int m, long identifierMask, unsigned int mide);
ecan2Filter(int n, long identifier, unsigned int exide,unsigned int bufPnt,unsigned int maskSel);
ecan2Mask(int m, long identifierMask, unsigned int mide);
3. Folder Contents:
-------------------
This folder contains the following sub-folders:
a. C:\Program Files\Microchip\MPLAB C30\support\gld
This folder will have the device GLD file, it is used for building the project.
This file was provided with the MPLAB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -