adcChannelScanning

所属分类:单片机开发
开发工具:C/C++
文件大小:21KB
下载次数:120
上传日期:2009-04-14 17:19:42
上 传 者jiajia08
说明:  dsPIC33F型号的CPU可配置10位或12位的ADC采样,转换完成后直接从DMA中读取转换结果。源码中对多路模拟量进行采样,对ADC及DMA分别进行了配置。
(dsPIC33F models of CPU can be configured 10-bit or 12-bit sampling ADC, the conversion after the completion of DMA read directly from the conversion results. Source of multi-channel analog sampling, the ADC and DMA configuration respectively.)

文件列表:
ADC Channel Scanning\ADC_Chscan.mcp (1004, 2007-03-13)
ADC Channel Scanning\ADC_Chscan.mcw (170496, 2007-03-20)
ADC Channel Scanning\h\adcDrv1.h (1901, 2007-03-20)
ADC Channel Scanning\h\tglPin.h (1816, 2007-03-21)
ADC Channel Scanning\src\adcDrv1.c (7494, 2007-03-20)
ADC Channel Scanning\src\main.c (4356, 2007-03-20)
ADC Channel Scanning\src\tglPin.s (3071, 2007-03-20)
ADC Channel Scanning\src\traps.c (5711, 2007-03-20)
ADC Channel Scanning\h (0, 2007-03-29)
ADC Channel Scanning\src (0, 2007-03-29)
ADC Channel Scanning (0, 2007-03-29)

Readme File for Code Example: CE120 - ADC Channel Scanning ---------------------------------------- This file contains the following sections: 1. Code Example Description 2. Folder Contents 3. Suggested Development Resources 4. Reconfiguring the project for a different dsPIC33F device 5. Revision History 1. Code Example Description: ---------------------------- In this example, Timer 3 is setup to time-out every 125 microseconds (8Khz Rate). As a result, the module will stop sampling and trigger a A/D conversion on every Timer3 time-out, i.e., Ts=125us. ADC is configured in 10bit mode to sequencially scan AIN4, AIN5, AIN10, AIN13 inputs on Timer 3 interrupt. It will take FOUR Timer3 Timeout period to scan through all the FOUR Analog inputs. ADC module clock time period is configured as Tad=Tcy*(ADCS+1)= (1/40M)**** = 1.6us (625Khz). Hence the conversion time for 10-bit A/D Conversion Time Tc=12*Tad = 19.2us DMA is used to sort and transfer the converted data to DMA RAM. DMA is configured in ping-pong mode and it transfers 8samples of each of the FOUR analog inputs and generates interrupt. DMA channel 0 is confiured in ping-pong mode to move the converted data from ADC to DMA RAM on every sample/convert sequence. First, DMA uses DMA0STA base address to store the ADC samples and it generates interrupt after transfering (4 x 8 samples = 32 samples). Next, DMA uses DMA0STB base address to store the ADC samples and it generates interrupt after transferubg (4 x 8 samples = 31 samples). Above process repeats contineously. void __attribute__((__interrupt__)) _DMA0Interrupt(void); DMA interrupt service routine, moves the data from DMA buffer to ADC signal buffer ISR rate will be (8k/32samples) = 250Hz for 8K ADC trigger rate from Timer. RA6 pin is toggled in ISR, hence it will be toggling at ~ 125Hz 2. 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. 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. f. src This folder contains all the C and Assembler source files (*.c, *.s) 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. 3. Suggested Development Resources: ----------------------------------- a. dsPICDEM1.1+ board with dsPIC33FJ256GP710 controller 4. 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. 5. Revision History : --------------------- 07/09/2006 - Initial Release of the Code Example

近期下载者

相关文件


收藏者