TI中文支持网
TI专业的中文技术问题咨询交流网站

TMS320F280021: 2800X系列的ADC的PIE中断和ADCINT1、ADCINT2的问题

Part Number:TMS320F280021

Dear all:

在使用2800X系列的ADC中断时发现下列问题:

2800x系列有ADCINT1、ADCINT2、ADCINT3、ADCINT4 共4个中断,

使用ADCINT1中断时,做了以下3个测试

1、使用PIE中断向量表的ADCA1作为中断入口时,中断程序能正常运行,运行结果正确,LED_FLASH管脚翻转的时间是17.2us,翻转80次

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

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1


EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A0  1:A1  2:A2  3:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10  B:A11// C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCA

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

定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count mode

ADC1中断函数
__interrupt void adc_A1ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN  = 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// 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 flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

2、使用PIE中断向量表的ADCC1作为中断入口时,中断程序不能运行,进不了中断

PieVectTable.ADCC1_INT  = &adc_C1ISR;// Function for ADCC interrupt 1

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx3 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A0  1:A1  2:A2  3:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10  B:A11// C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCA

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

定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count mode

ADC1中断函数
__interrupt void adc_C1ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN  = 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// 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 flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

3、使用PIE中断向量表的ADCA2作为中断入口时,中断程序不能运行,进不了中断

PieVectTable.ADCA2_INT  = &adc_A2ISR;// Function for ADCA interrupt 1

IER |= M_INT10; //ADCINT1

PieCtrlRegs.PIEIER10.bit.INTx2 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A0  1:A1  2:A2  3:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10  B:A11// C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCA

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

定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count mode

ADC1中断函数
__interrupt void adc_A2ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN  = 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// 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 flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

使用ADCINT2中断时,做了以下2个测试

4、使用PIE中断向量表的ADCA1作为中断入口时,中断程序不能运行,进不了中断

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

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1


EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A0  1:A1  2:A2  3:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10  B:A11// C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 0; // End of SOC1 will set INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;// Enable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;//不连续
AdcaRegs.ADCINTFLGCLR.bit.ADC2NT1 = 1; // Make sure INT2 flag is cleared

定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count mode

ADC1中断函数
__interrupt void adc_A1ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN  = 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// Clear the interrupt flag//AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;//// Check if overflow has occurred//if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2){AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT2 overflow flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT2 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

5、使用PIE中断向量表的ADCA2作为中断入口时,中断程序可以运行,但是运行结果不正常,LED_FLASH管脚翻转的时间是20ms(我设定的是17.2us)

PieVectTable.ADCA2_INT  = &adc_A2ISR;// Function for ADCA interrupt 1

IER |= M_INT10; //ADCINT1

PieCtrlRegs.PIEIER10.bit.INTx2 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A0  1:A1  2:A2  3:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10  B:A11// C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 0; // End of SOC1 will set INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;// Enable INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;//不连续
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; // Make sure INT1 flag is cleared

定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count mode

ADC1中断函数
__interrupt void adc_A2ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN  = 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// Clear the interrupt flag//AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;//// Check if overflow has occurred//if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2){AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT1 overflow flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT1 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

我的问题:

1、如何配置在ADCINT1中断1时,使用PIE中断向量表的ADCA2中断入口,中断程序正常运行。

2、如何配置在ADCINT2中断2时,使用PIE中断向量表的ADCA1中断入口,中断程序正常运行。

3、如何配置在ADCINT2中断2时,使用PIE中断向量表的ADCA2中断入口,中断程序正常运行,目前能进行中断,运行不正常。

Cherry Zhou:

您好,我们已收到您的问题并升级到英文论坛寻求帮助,如有答复将尽快回复您。谢谢!

,

Cherry Zhou:

您好,在您进行的测试2中,虽然 ADCC1 是中断配置,但并未配置ADCC,因此不会生成 ADCC1 中断。

测试3中,没有设置ADCINT2 的 EOC 触发器:

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

,

Huit Wu:

我总共做了5个分类测试,测试3我本身就是使用ADCINT1中断,只是把中断PIE配置为ADCA2向量也就是INT10.2 ,所以配置的是ADCINT1的EOC触发,

我也英文论坛也可以到了类似的问题,分了两组ADC-A和ADC-C ,

ADC-A组

ADCINT1对应的PIE中断是ADCA1 ,ADCINT2对应的PIE中断是ADCA2,ADCINT3对应的PIE中断是ADCA3,ADCINT4对应的PIE中断是ADCA4

ADC-C组

ADCINT1对应的PIE中断是ADCC1 ,ADCINT2对应的PIE中断是ADCC2,ADCINT3对应的PIE中断是ADCC3,ADCINT4对应的PIE中断是ADCC4

现在我使用的是ADC-A组,使用ADCINT2对应的PIE中断是ADCA2的配置,使用epwm触发ADC中断,我把我这个程序再上传,但是中断转换的时间是20ms,

不管是怎么配置epwm触发的周期。

PieVectTable.ADCA2_INT= &adc_A2ISR;// Function for ADCA interrupt 2IER |= M_INT10; //ADCINT2PieCtrlRegs.PIEIER10.bit.INTx2 = 1;// ADCINT2EPwm1Regs.ETSEL.bit.SOCAEN = 0;// Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;// Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;// Generate pulse on 1st eventEPwm1Regs.CMPA.bit.CMPA = 430;// Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;// Set period to 4096 countsEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Freeze counterAdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;// SOC0 will convert pin A1// 0:A01:A12:A23:A3// 4:A45:A56:A67:A7// 8:A89:A9A:A10B:A11// C:A12D:A13E:A14F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;// Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;// Trigger on ePWM1 SOCAAdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 0; // End of SOC0 will set INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;// Enable INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;//不连续
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; // Make sure INT1 flag is cleared定时器函数里25ms启动ePWM 转换
EPwm1Regs.ETSEL.bit.SOCAEN= 1;// Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;// Unfreeze, and enter up count modeADC1中断函数
__interrupt void adc_A2ISR(void)
{LED_FLASH=1;Current.Sum+=AdcaResultRegs.ADCRESULT1;if(++Current.ConversionCount==80){Current.ConversionCount=0;Current.Data=(Current.Sum/80);Current.Sum=0;EALLOW;EPwm1Regs.ETSEL.bit.SOCAEN= 0;// Enable SOC on A groupEPwm1Regs.TBCTL.bit.CTRMODE = 3;// Unfreeze, and enter up count modeEDIS;}//// Clear the interrupt flag//AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;//// Check if overflow has occurred//if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2){AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT2 overflow flagAdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT2 flag}//// Acknowledge the interrupt//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;}

帮忙分析使用ADCINT2对应的PIE中断是ADCA2,中断转换时间异常一直20ms这个问题。

,

Huit Wu:

我重新又测试了一把,使用ADCINT3对应的PIE中断是ADCA3,ADCINT4对应的PIE中断是ADCA4测试,结果和ADCINT2对应的PIE中断是ADCA2,中断转换时间异常一直20ms,但是使用使用ADCINT1对应的PIE中断是ADCA1就是正常的,

EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A groupEPwm1Regs.ETSEL.bit.SOCASEL = 3; // Select SOC on up-countEPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430; // Set compare A value to 2048 countsEPwm1Regs.TBPRD = 862; // Set period to 4096 counts

是不epwm触发这块要特别配置?

,

Cherry Zhou:

好的感谢您提供的信息,因负责该问题的专家休假,预计给到您答复会在下周工作日之内,给您带来的不便敬请谅解!

,

Huit Wu:

犯了一个不该错误导致,中断清零出错了,使用了IER |= M_INT10; //ADCINT2

清零要使用PieCtrlRegs.PIEACK.bit.ACK10=1;

,

Huit Wu:

感谢你们的帮助

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F280021: 2800X系列的ADC的PIE中断和ADCINT1、ADCINT2的问题
分享到: 更多 (0)