Board logo

标题: 28027在CCS中的ADC模块的程序改不了寄存器的值!为什么呢? [打印本页]

作者: reporter    时间: 2013-10-31 10:11     标题: 28027在CCS中的ADC模块的程序改不了寄存器的值!为什么呢?

F28027在CCS中的ADC模块的程序在调试时改不了寄存器的值,这是为什么呢??应该已经使能ADC模块了的。
附源程序:

#include "DSP28x_Project.h"   
interrupt void tim0_isr(void);
interrupt void ADC_convered(void);
Uint16 ADCINA0_Voltage_sum = 0;
Uint16 ADCINA1_Voltage_sum = 0;
Uint16 ADCINA2_Voltage_sum = 0;
Uint16 ADCINA0_Voltage = 0;
Uint16 ADCINA1_Voltage = 0;
Uint16 ADCINA2_Voltage = 0;
char convered_count = 0;
void main(void)
{
  InitSysCtrl();
   InitGpio();
  DINT;
  InitPieCtrl();
IER = 0x0000;    IFR = 0x0000;
InitPieVectTable();
    InitAdc();
    EALLOW;
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 0; //SOC0、SOC1单一采样   
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2 = 0; //SOC2、SOC3单一采样   
AdcRegs.ADCSOC0CTL.bit.CHSEL=0;   //SOC通道选择      
AdcRegs.ADCSOC1CTL.bit.CHSEL=1;      
AdcRegs.ADCSOC2CTL.bit.CHSEL=2;      
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;  //采样时间      
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;      
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;      
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 1;  //soc触发选择,TIM0   
AdcRegs.ADCCTL1.bit.INTPULSEPOS  = 1;   //结果存入寄存器才产生中断
    PieVectTable.ADCINT1 = &ADC_convered;   
AdcRegs.INTSEL1N2.bit.INT1SEL = 2;    //中断线1选择soc2   
AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;   
AdcRegs.INTSEL1N2.bit.INT1E  = 1;    //中断使能
    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;   //使能int1.1     EDIS;
/****************设置定时器,用以触发ADC*****************/   
CpuTimer0Regs.TPR.bit.TDDR = 59;   
CpuTimer0Regs.TPRH.bit.TDDRH = 0; //对输入时钟60分频,60M/60=1M   
CpuTimer0Regs.PRD.all = 500000;//定时0.5s   
CpuTimer0Regs.TCR.bit.TRB = 1; //reload   
CpuTimer0Regs.TCR.bit.TIE = 1; //使能中断   
CpuTimer0Regs.TCR.bit.TSS = 0; //开始计数
    EALLOW;    &nbspieVectTable.TINT0 = &tim0_isr;   
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   //使能PIE   
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;   //使能int1.7   
IER |= 0x0001;//使能GROUP1   
EINT;   
EDIS;
  }
interrupt void ADC_convered(void)
{      //LED_toggle(LED2);     
ADCINA0_Voltage_sum += AdcResult.ADCRESULT0;     
ADCINA1_Voltage_sum += AdcResult.ADCRESULT1;     
ADCINA2_Voltage_sum += AdcResult.ADCRESULT2;     
AdcRegs.ADCINT标志寄存器CLR.bit.ADCINT1 = 1;     
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;     
convered_count++;     
/*********转换16次,取平均值*********/     
if(convered_count > 15)     
{          ADCINA0_Voltage = ADCINA0_Voltage_sum >> 4;//相当于除以16         
            ADCINA1_Voltage = ADCINA1_Voltage_sum >> 4;         
           ADCINA2_Voltage = ADCINA2_Voltage_sum >> 4;         
           ADCINA0_Voltage_sum = 0;         
           ADCINA1_Voltage_sum = 0;         
          ADCINA2_Voltage_sum = 0;         
            convered_count = 0;      }  
}
  interrupt void tim0_isr(void)
{    &nbspieCtrlRegs.PIEACK.all = PIEACK_GROUP1;  }
//===========================================================================
// No more.
//===========================================================================




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0