在利用28031的内部ADC采样9路通道时遇到问题,软件触发,总是进不去ADCINT1中断,
上论坛发帖没有得到技术支持,只好研究例程,在例程里面有个Example_2803xOscComp.c
的 工程,用的是ADCINT1采样温度传感器,软件触发,但是采用的是查询,我把它改成了
ADCINT1中断,仍然是软件触发,发现还是进不去ADCINT1中断,请问到底有没有技术
支持懂这个的?请指导下,详细代码如下:
#include "DSP28x_Project.h" // DSP28x Headerfil
int16 temp; //Temperature sensor reading
interrupt void adc_isr(void);
unsigned char internal_adc_interrupt_flag;
void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// Enable XCLOCKOUT to allow monitoring of oscillator 1
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 3; //enable XCLOCKOUT through GPIO mux
SysCtrlRegs.XCLK.bit.XCLKOUTDIV = 2; //XCLOCKOUT = SYSCLK
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2803x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2803x_DefaultIsr.c.
// This function is found in DSP2803x_PieVect.c.
InitPieVectTable();
EALLOW;
PieVectTable.ADCINT1 = &adc_isr;//使用ADCINT1
EDIS;
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Configure the ADC:
// Initialize the ADC
//InitAdcAio();
InitAdc();
EALLOW;
AdcRegs.ADCCTL1.bit.TEMPCONV = 1; //Connect channel A5 internally to the temperature sensor
AdcRegs.ADCSOC0CTL.bit.CHSEL = 5; //Set SOC0 channel select to ADCINA5
AdcRegs.ADCSOC1CTL.bit.CHSEL = 5; //Set SOC1 channel select to ADCINA5
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //Set SOC0 acquisition period to 7 ADCCLK
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //Set SOC1 acquisition period to 7 ADCCLK
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //Connect ADCINT1 to EOC1
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enable ADCINT1
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 starts SOC0-7
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1;
AdcRegs.INTSEL1N2.bit.INT1CONT = 0;
// Note: two channels have been connected to the temp sensor
// so that the first sample can be discarded to avoid the
// ADC first sample issue. See the device errata.
// Set the flash OTP wait-states to minimum. This is important
// for the performance of the compensation function.
FlashRegs.FOTPWAIT.bit.OTPWAIT = 1;
IER |= M_INT1;////含有ADCINT1
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
EINT;
ERTM;
AdcRegs.ADCSOCFRC1.all = 0x03;
//Main program loop
for(;;)
{
// Sample temperature sensor. Note: the end application will
// be responsible for deciding how and when to sample the
// temperature sensor so that the value can be passed to the
// compensation function
asm(" RPT #8 || NOP ");
//Get temp sensor sample result from SOC1
if(internal_adc_interrupt_flag == 1)
temp = AdcResult.ADCRESULT1;
//Use temp sensor measurement to perform oscillator compensation even as temperature changes.
Osc1Comp(temp);
internal_adc_interrupt_flag = 0;
//Osc2Comp(temp); //Also possible to recalibrate osc. 2
//...other application tasks here...
}
}
interrupt void adc_isr(void)
{
//Force start of conversion on SOC0 and SOC1
AdcRegs.ADCSOCFRC1.all = 0x03;
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1
internal_adc_interrupt_flag = 1;//置1代表进入了ADC中断
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
}