zhangmangui 发表于 2013-7-19 09:06
你用双极性的那就有负数了 嗯 公式是对的
每个通道采集都是128次,就是我想看看每次采集之间的时间应该在程序哪看呢?
这是这个AD程序的代码
/**********************************************************************
* File: nain_nonBIOS.c
* Devices: TMS320F2812, TMS320F2811, TMS320F2810
* Author: Saber, ICETEK.
* History:
* 2010/04/07 - original
**********************************************************************/
#include "DSP281x_Device.h"
#include "example_nonBIOS.h"
//if you want to run in FLASH:
//1.Enable the define "EXAMPLE_FLASH"
//2.Remove "F2812_nonBIOS_RAM.cmd"
//3.Add the "F2812.cmd"
//#define EXAMPLE_FLASH
#define StartCpuTimer0() CpuTimer0Regs.TCR.bit.TSS = 0
#define ADSmple 128
#define AD_CONVST (*((Uint16 *)0x2800))
#define AD_CHIPSEL0 (*((Uint16 *)0x2200))
#define AD_CHIPSEL1 (*((Uint16 *)0x2000))
#pragma DATA_SECTION(ADSampleResult0,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult1,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult2,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult3,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult4,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult5,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult6,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult7,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult8,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult9,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult10,"GlobalVar");
#pragma DATA_SECTION(ADSampleResult11,"GlobalVar");
int ADSampleResult0[ADSmple]; //AD通道0数据
int ADSampleResult1[ADSmple]; //AD通道1数据
int ADSampleResult2[ADSmple]; //AD通道2数据
int ADSampleResult3[ADSmple]; //AD通道3数据
int ADSampleResult4[ADSmple]; //AD通道4数据
int ADSampleResult5[ADSmple]; //AD通道5数据
int ADSampleResult6[ADSmple]; //AD通道0数据
int ADSampleResult7[ADSmple]; //AD通道1数据
int ADSampleResult8[ADSmple]; //AD通道2数据
int ADSampleResult9[ADSmple]; //AD通道3数据
int ADSampleResult10[ADSmple]; //AD通道4数据
int ADSampleResult11[ADSmple]; //AD通道5数据
void User_Init(void);
interrupt void cpu_timer0_isr(void);
Uint16 Count = 0;
/**********************************************************************
* Function: main()
*
* Description: Main function for F281x example.
**********************************************************************/
void main(void)
{
/*** CPU Initialization ***/
InitSysCtrl(); //Initialize the CPU (FILE: SysCtrl.c)
DINT;
IER = 0x0000; // Disable CPU interrupts
IFR = 0x0000; // Clear all CPU interrupt flags
InitXintf(); //Initialize the external memory interface (FILE: Xintf.c)
//InitGpio(); // Initialize the shared GPIO pins (FILE: Gpio.c)
InitPieCtrl(); // Initialize and enable the PIE (FILE: PieCtrl.c)
InitEv(); // Initialize the EV(FILE: Ev.c)--And initialize the Timer1
InitCpuTimers(); // Initialize the time (FILE: DSP281x_CpuTimers.c)
#ifdef EXAMPLE_FLASH
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash();
#endif
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &cpu_timer0_isr;//timer0中断服务子程序重定位
EDIS; // This is needed to disable write to EALLOW protected registers
IER |= M_INT1; // EV Interrupt
IFR &= 0x0000; //Clear all interrupt flag
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
//SetDBGIER(IER); // Configure the DBGIER for realtime debug
EINT; // Enable global interrupts and realtime debug
//asm(" CLRC INTM, DBGM");
StartCpuTimer0();
/*** Main Cycle ***/
while(1)
{
;
}
}// End of main
interrupt void cpu_timer0_isr(void)
{
if(Count < ADSmple)
{
AD_CONVST=0xf;//停止AD转换 准备读出AD通道数据
ADSampleResult0[Count]=AD_CHIPSEL0;
ADSampleResult1[Count]=AD_CHIPSEL0;
ADSampleResult2[Count]=AD_CHIPSEL0;
ADSampleResult3[Count]=AD_CHIPSEL0;
ADSampleResult4[Count]=AD_CHIPSEL0;
ADSampleResult5[Count]=AD_CHIPSEL0;
ADSampleResult6[Count]=AD_CHIPSEL1;
ADSampleResult7[Count]=AD_CHIPSEL1;
ADSampleResult8[Count]=AD_CHIPSEL1;
ADSampleResult9[Count]=AD_CHIPSEL1;
ADSampleResult10[Count]=AD_CHIPSEL1;
ADSampleResult11[Count]=AD_CHIPSEL1;
AD_CONVST=0x0; //重新启动AD转换
Count++;
}
else
{
Count = 0;
}
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
/*** end of file ***/
|