TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F280021: F280021使用定时器触发AD AD进不了中断

Part Number:TMS320F280021

Dear all:

     在调试ADC时发现,采用定时器0 触发AD,AD进不了AD中断:

我的程序如下:

void initADC(void)
{
//
// Setup VREF as internal
//
SetVREF(ADC_ADCA, ADC_INTERNAL, ADC_VREF3P3);
//SetVREF(ADC_ADCA, ADC_EXTERNAL, ADC_VREF2P5);

EALLOW;

//
// Set ADCCLK divider to /4
//
AdcaRegs.ADCCTL2.bit.PRESCALE = 6;

//
// Set pulse positions to late
//
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//
// Power up the ADC and then delay for 1 ms
//
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
EDIS;

DELAY_US(1000);
}

void initADCSOC(void)
{
//
// Select the channels to convert and the end of conversion flag
//
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin A1
// 0:A0 1:A1 2:A2 3:A3
// 4:A4 5:A5 6:A6 7:A7
// 8:A8 9:A9 A:A10 B:A11
// C:A12 D:A13 E:A14 F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 25; // Sample window is 10 SYSCLK cycles

AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //Timer0

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

EDIS;
}

//
// adcA1ISR - ADC A Interrupt 1 ISR
//
__interrupt void adcA1ISR(void)
{
static Uint16 *AdcBufPtr1 = Voltage1; // Pointer to ADC data buffer

IOTEST=1;

if((Time <= 0)||(Time > RFFT_SIZE))
{
Time = 0;
}
else
{
Time--;
*AdcBufPtr1++ = AdcaResultRegs.ADCRESULT0;
}
//
// Clear the interrupt flag
//
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

//
// Check if overflow has occurred
//
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
{
AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
}

//
// Acknowledge the interrupt
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

void main(void)
{
InitSysCtrl();//100M

InitGpio();

DINT;

InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

EALLOW;
PieVectTable.TIMER0_INT = &cpuTimer0ISR;

PieVectTable.ADCA1_INT = &adcA1ISR; // Function for ADCA interrupt 1

EDIS;
//
// Initialize the Device Peripheral. For this example, only initialize the
// Cpu Timers.
//

InitGpioAll();

InitCpuTimers();

ConfigCpuTimer(&CpuTimer0, 100, 2);//AD采样时间
// hans函数里面定时器中断不使能  Timer->RegsAddr->TCR.bit.TIE = 0;



initADC();

initADCSOC();







IER |= M_INT1;//T0 ADCINT1


//
// Enable TINT0 in the PIE: Group 1 interrupt 7
//
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;//T0



//
// Enable global Interrupts and higher priority real-time debug events
//
EINT;
ERTM;



while(1)
{Time=RFFT_SIZE;StartCpuTimer0();//CpuTimer0Regs.TCR.bit.TSS = 0while(1){if(Time == 0){break;}StopCpuTimer0();//CpuTimer0Regs.TCR.bit.TSS = 1}

}

Huit:

配置定时0时,定时器0是不进入中断的,只是采用定时器去触发AD中断,但是AD中断函数里进入不了,不知道是什么原因导致的?

,

Susan Yang:

建议您使用回复框下面的“插入”功能来插入代码,以便于查看

,

Huit:

void initADC(void)
{
//
// Setup VREF as internal
//
SetVREF(ADC_ADCA, ADC_INTERNAL, ADC_VREF3P3);
//SetVREF(ADC_ADCA, ADC_EXTERNAL, ADC_VREF2P5);EALLOW;//
// Set ADCCLK divider to /4
//
AdcaRegs.ADCCTL2.bit.PRESCALE = 6;//
// Set pulse positions to late
//
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;//
// Power up the ADC and then delay for 1 ms
//
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
EDIS;DELAY_US(1000);
}void initADCSOC(void)
{
//
// Select the channels to convert and the end of conversion flag
//
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin A1
// 0:A0 1:A1 2:A2 3:A3
// 4:A4 5:A5 6:A6 7:A7
// 8:A8 9:A9 A:A10 B:A11
// C:A12 D:A13 E:A14 F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 25; // Sample window is 10 SYSCLK cyclesAdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //Timer0AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is clearedEDIS;
}//
// adcA1ISR - ADC A Interrupt 1 ISR
//
__interrupt void adcA1ISR(void)
{
static Uint16 *AdcBufPtr1 = Voltage1; // Pointer to ADC data bufferIOTEST=1;if((Time <= 0)||(Time > RFFT_SIZE))
{
Time = 0;
}
else
{
Time--;
*AdcBufPtr1++ = AdcaResultRegs.ADCRESULT0;
}
//
// Clear the interrupt flag
//
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//
// Check if overflow has occurred
//
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
{
AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
}//
// Acknowledge the interrupt
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;}void main(void)
{
InitSysCtrl();//100MInitGpio();DINT;InitPieCtrl();IER = 0x0000;
IFR = 0x0000;InitPieVectTable();EALLOW;
PieVectTable.TIMER0_INT = &cpuTimer0ISR;PieVectTable.ADCA1_INT = &adcA1ISR; // Function for ADCA interrupt 1EDIS;
//
// Initialize the Device Peripheral. For this example, only initialize the
// Cpu Timers.
//InitGpioAll();InitCpuTimers();ConfigCpuTimer(&CpuTimer0, 100, 2);//AD采样时间// hans函数里面定时器中断不使能Timer->RegsAddr->TCR.bit.TIE = 0;initADC();initADCSOC();IER |= M_INT1;//T0 ADCINT1//
// Enable TINT0 in the PIE: Group 1 interrupt 7
//
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;//T0//
// Enable global Interrupts and higher priority real-time debug events
//
EINT;
ERTM;while(1)
{Time=RFFT_SIZE;StartCpuTimer0();//CpuTimer0Regs.TCR.bit.TSS = 0while(1){if(Time == 0){break;}StopCpuTimer0();//CpuTimer0Regs.TCR.bit.TSS = 1}

代码如上

,

Susan Yang:

抱歉,还没来得及测试。请问您是解决问题了?

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F280021: F280021使用定时器触发AD AD进不了中断
分享到: 更多 (0)