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

28035 最后两个采样通道结果寄存器值始终为0

如题,代码如下:

void ADC_Config(void)

{
InitAdc(); // For this example, init the ADC

EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT3 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode
AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=0; //SOC0,SOC1 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable

AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1 ADCINB0
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //SOC2 ADCINA1
AdcRegs.ADCSOC3CTL.bit.CHSEL = 0; //SOC3 ADCINA0
AdcRegs.ADCSOC4CTL.bit.CHSEL = 0; //SOC4 ADCINA0
AdcRegs.ADCSOC5CTL.bit.CHSEL = 0; //SOC5 ADCINA0

//AD选择触发源,软件触发 P34
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
EDIS;
}

//————————————————————————-
//AD 中断处理函数
//
//##########################################################################
interrupt void adc_isr(void)
{
EALLOW;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge interrupt to PIE
EDIS;

AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //Clear ADCINT1 flag reinitialize for next SOC
}

仿真结果见附件。

如果把PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr,则不进入中断了;

囧:

你的代码只使能了 ADCINT3,当然ADCINT5 进不了中断。

AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3

如题,代码如下:

void ADC_Config(void)

{
InitAdc(); // For this example, init the ADC

EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT3 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode
AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=0; //SOC0,SOC1 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable

AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1 ADCINB0
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //SOC2 ADCINA1
AdcRegs.ADCSOC3CTL.bit.CHSEL = 0; //SOC3 ADCINA0
AdcRegs.ADCSOC4CTL.bit.CHSEL = 0; //SOC4 ADCINA0
AdcRegs.ADCSOC5CTL.bit.CHSEL = 0; //SOC5 ADCINA0

//AD选择触发源,软件触发 P34
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
EDIS;
}

//————————————————————————-
//AD 中断处理函数
//
//##########################################################################
interrupt void adc_isr(void)
{
EALLOW;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge interrupt to PIE
EDIS;

AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //Clear ADCINT1 flag reinitialize for next SOC
}

仿真结果见附件。

如果把PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr,则不进入中断了;

kang yu:

回复 囧:

把“PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr”,则不进入中断了,我在帖子末端特地说明了。代码使用的最后一个SOC是SOC5,没必要就要用ADCINT5。因为,总共有16个SOC,如果用SOC15,ADCINT怎么选。

如题,代码如下:

void ADC_Config(void)

{
InitAdc(); // For this example, init the ADC

EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT3 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode
AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=0; //SOC0,SOC1 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable

AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1 ADCINB0
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //SOC2 ADCINA1
AdcRegs.ADCSOC3CTL.bit.CHSEL = 0; //SOC3 ADCINA0
AdcRegs.ADCSOC4CTL.bit.CHSEL = 0; //SOC4 ADCINA0
AdcRegs.ADCSOC5CTL.bit.CHSEL = 0; //SOC5 ADCINA0

//AD选择触发源,软件触发 P34
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
EDIS;
}

//————————————————————————-
//AD 中断处理函数
//
//##########################################################################
interrupt void adc_isr(void)
{
EALLOW;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge interrupt to PIE
EDIS;

AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //Clear ADCINT1 flag reinitialize for next SOC
}

仿真结果见附件。

如果把PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr,则不进入中断了;

kang yu:

回复 kang yu:

使用ADCINT5不进入中断,猜测原因是:最后两个通道根本没有启动转换,于是没有EOC信号,也就不能触发中断了

如题,代码如下:

void ADC_Config(void)

{
InitAdc(); // For this example, init the ADC

EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT3 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode
AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=0; //SOC0,SOC1 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable

AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1 ADCINB0
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //SOC2 ADCINA1
AdcRegs.ADCSOC3CTL.bit.CHSEL = 0; //SOC3 ADCINA0
AdcRegs.ADCSOC4CTL.bit.CHSEL = 0; //SOC4 ADCINA0
AdcRegs.ADCSOC5CTL.bit.CHSEL = 0; //SOC5 ADCINA0

//AD选择触发源,软件触发 P34
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
EDIS;
}

//————————————————————————-
//AD 中断处理函数
//
//##########################################################################
interrupt void adc_isr(void)
{
EALLOW;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge interrupt to PIE
EDIS;

AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //Clear ADCINT1 flag reinitialize for next SOC
}

仿真结果见附件。

如果把PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr,则不进入中断了;

囧:

回复 kang yu:

AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

你现在设置的是EOC3触发触发中断啊,如果你想让SOC5采样完再中断,那应该设置为5

如题,代码如下:

void ADC_Config(void)

{
InitAdc(); // For this example, init the ADC

EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT3 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode
AdcRegs.INTSEL3N4.bit.INT3SEL = 3; //setup EOC3 to trigger ADCINT3 to fire

AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=0; //SOC0,SOC1 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=0; //SOC2,SOC3 SEQUENTIAL Sampling Enable

AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; //SOC1 ADCINB0
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //SOC2 ADCINA1
AdcRegs.ADCSOC3CTL.bit.CHSEL = 0; //SOC3 ADCINA0
AdcRegs.ADCSOC4CTL.bit.CHSEL = 0; //SOC4 ADCINA0
AdcRegs.ADCSOC5CTL.bit.CHSEL = 0; //SOC5 ADCINA0

//AD选择触发源,软件触发 P34
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 0x00; //ADCTRIG0- Software only

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
EDIS;
}

//————————————————————————-
//AD 中断处理函数
//
//##########################################################################
interrupt void adc_isr(void)
{
EALLOW;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge interrupt to PIE
EDIS;

AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //Clear ADCINT1 flag reinitialize for next SOC
}

仿真结果见附件。

如果把PieVectTable.ADCINT3 = &adc_isr换成PieVectTable.ADCINT5 = &adc_isr,则不进入中断了;

kang yu:

回复 囧:

找到原因了

AdcRegs.ADCSOCFRC1.all = 0X003F;

原来AdcRegs.ADCSOCFRC1.all = 0X000F,所以始终只有SOC0、SOC1、SOC2、SOC3转换。改正后,结果寄存器就有结果了

赞(0)
未经允许不得转载:TI中文支持网 » 28035 最后两个采样通道结果寄存器值始终为0
分享到: 更多 (0)