DSPIC33F_ECAN__DMA_Crosswire

所属分类:DSP编程
开发工具:C/C++
文件大小:450KB
下载次数:0
上传日期:2019-01-17 12:43:46
上 传 者powerhwh
说明:  DSPIC33F写的CAN通信源码,很有借鉴意义。
(The CAN communication source code written by DSPIC33F is very useful for reference.)

文件列表:
ECAN__DMA_Crosswire\ECANCodeExample1.mcp (1799, 2019-01-17)
ECAN__DMA_Crosswire\ECANCodeExample1.mcs (4462, 2019-01-17)
ECAN__DMA_Crosswire\ECANCodeExample1.mcw (978944, 2019-01-17)
ECAN__DMA_Crosswire\h (0, 2009-04-14)
ECAN__DMA_Crosswire\h\common.h (3478, 2007-09-13)
ECAN__DMA_Crosswire\h\ECAN1Config.h (3451, 2007-09-13)
ECAN__DMA_Crosswire\h\ECAN1Drv.h (3458, 2007-09-13)
ECAN__DMA_Crosswire\h\ECAN2Config.h (3447, 2007-09-13)
ECAN__DMA_Crosswire\h\ECAN2Drv.h (3458, 2007-09-13)
ECAN__DMA_Crosswire\hex (0, 2009-04-14)
ECAN__DMA_Crosswire\hex\ECANCodeExample1.cof (1631385, 2009-04-14)
ECAN__DMA_Crosswire\hex\ECANCodeExample1.hex (28534, 2009-04-14)
ECAN__DMA_Crosswire\hex\ECANCodeExample1.map (133430, 2009-04-14)
ECAN__DMA_Crosswire\src (0, 2019-01-17)
ECAN__DMA_Crosswire\src\ECAN1Config.C (6320, 2007-09-13)
ECAN__DMA_Crosswire\src\ECAN1Config.o (251345, 2019-01-17)
ECAN__DMA_Crosswire\src\ECAN1Drv.c (11193, 2007-09-13)
ECAN__DMA_Crosswire\src\ECAN1Drv.o (254405, 2019-01-17)
ECAN__DMA_Crosswire\src\ECAN2Config.C (6318, 2007-09-13)
ECAN__DMA_Crosswire\src\ECAN2Config.o (251375, 2019-01-17)
ECAN__DMA_Crosswire\src\ECAN2Drv.c (11183, 2007-09-13)
ECAN__DMA_Crosswire\src\ECAN2Drv.o (254405, 2019-01-17)
ECAN__DMA_Crosswire\src\hex (0, 2019-01-17)
ECAN__DMA_Crosswire\src\main.c (15864, 2007-09-13)
ECAN__DMA_Crosswire\src\main.o (259765, 2019-01-17)
ECAN__DMA_Crosswire\src\traps.c (5708, 2007-09-13)
ECAN__DMA_Crosswire\src\traps.o (251328, 2019-01-17)

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 = *** (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 C30 toolsuite. The following file is used in this project - dsPIC33FJ256GP710.gld b. C:\Program Files\Microchip\MPLAB C30\support\h This folder contains C header files useful in building this project. Device register and bit definitions are provided in the *.h file that follows the device name. These files were provided with the MPLAB C30 toolsuite. c. C:\Program Files\Microchip\MPLAB C30\lib This folder contains library archive files, which are a collection of precompiled object files. The file named "libpic30-coff.a" contains the C run-time start-up library. These file were provided with the MPLAB C30 toolsuite. d. hex This folder contains three file types - coff, hex and map. These are files generated by the MPLAB C30 toolsuite on build operation performed within MPLAB IDE. The *.map file contains details on memory allocation for various variables, constants and dsPIC instructions specified in the source and library code. The *.hex file contains a binary file that may be programmed into the dsPIC device. The *.coff file contains a binary file that is used by MPLAB IDE for simulation. e. h This folder contains include files for the code example. The following files are used in this project ECAN1Config.h ECAN2Config.h ECAN1Drv.h ECAN2Drv.h f. src This folder contains all the C source files (*.c) used in demonstrating the described example. This folder also contains a sub-folder named "obj" that stores compiled object files generated when the project is built. The following files are used in this project ECAN1Config.c ECAN2Config.c ECAN1Drv.c ECAN2Drv.c 4. Suggested Development Resources: ----------------------------------- a. Explorer 16 Demo board with dsPIC33FJ256GP710 controller b. ECAN PicTail Card 5. Reconfiguring the project for a different dsPIC33F device: ------------------------------------------------------------- The Project/Workspace can be easily reconfigured for any dsPIC33F device. Please use the following general guidelines: a. Change device selection within MPLAB IDE to a dsPIC33F device of your choice by using the following menu option: MPLAB IDE>>Configure>>Select Device b. Provide the correct device linker script and header file for your device. Device linker scripts and header files are available in your MPLAB C30 installation folder under: Device Linker Script- YourDrive:>Program Files\Microchip\MPLAB C30\support\gld Device C Header file- YourDrive:>Program Files\Microchip\MPLAB C30\support\h Device ASM Include file- YourDrive:>Program Files\Microchip\MPLAB C30\support\inc c. Provide the appropriate path to your MPLAB C30 support file locations using the menu option: MPLAB IDE>>Project>>Build Options>>Project d. Chose the development board applicable to your device. Some options are provided below: e. Re-build the MPLAB project using the menu option: MPLAB IDE>>Project>>Build All f. Download the hex file into the device and run. 6. Revision History : --------------------- 10/05/2006 - Initial Release of the Code Example

近期下载者

相关文件


收藏者