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

28035 ADC用软件直接触发的问题

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

ChongWen Zhao:

回复 Forrest:

谢谢您,果然OK了。

另外多说一句,为了避免28035本身的问题,建议在使用软件触发时将两个SOC一起设置,如程序中所示,否则有可能还是开启不了ADC

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

10#:

回复 ChongWen Zhao:

设置两个SOC的目的是为了丢弃第一个采样值 — 因为每个采样序列的第一个可能不准确(请查看Piccolo B勘误表),它不会导致ADC不能启动。

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

Forrest:

回复 10#:

楼主,楼上说的没有错。

另外楼主,如果不“使用软件触发时将两个SOC一起设置,如程序中所示,否则有可能还是开启不了ADC”那这就是BUG,这不会发生的,楼主放心。

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

ChongWen Zhao:

回复 10#:

谢谢您,您的解答对我帮助很大,更加明白了ADC的设置。

用EPWM触发的例程就是ADC_SOC那个是可以正确触发ADC的,说明ADC正常。

我改为在每个中断中都加入了软件触发的语句,这样就正常了。

不过,还请高人给予指点一二:请问如何正确设置软件触发的连续采样,有没有可能就是软件触发后,通过ADCINT1直接触发SOC,进行连续采样的设置?

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

ChongWen Zhao:

回复 Forrest:

谢谢您的指导,祝愉快!如方便能否再解答一下我提出的另一个问题?

各位好,

我想使用软件触发ADC进行连续采样,但是我将.ADCSOCFRC1位置1后,在WATCH WINDOW中看.ADCSOCFRC1仍然是0,,

因此ADC也没有正确工作,希望各位看下代码帮我找找原因,谢谢。

————————————————————————————————

void main()
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interruptsDINT;
InitEPwm6Gpio();
// 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 DSP2833x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT1 = &adc_isr;
// Enable ADCINT1 in PIE
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE
EDIS;// This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
InitEPwm6();

// Step 5. User specific code, enable interrupts:
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

LoopCount = 0;
ConversionCount = 0;

for(i=0;i<512;i++)
{
SampleTable[ConversionCount] = 0;
ConversionCount++;
}
ConversionCount = 0;

Adc_Config();
//Force start of conversion on SOC0
EALLOW;
AdcRegs.ADCSOCFRC1.all = 0x03;
EDIS;

for(;;)
{
asm("NOP");


}
}
interrupt void adc_isr(void)
{
//Wait for end of conversion.
while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//Clear ADCINT1

SampleTable[ConversionCount] = AdcResult.ADCRESULT0;
// If 512 conversions have been logged, start over
if(ConversionCount == 512)
{
ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;// Acknowledge interrupt to PIE

return;
}
void Adc_Config()
{
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E= 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSOC0CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC1CTL.bit.CHSEL = 7; //set SOC1 channel select to ADCINA7
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 0; //set SOC1 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
} —————————————————————————————————————————————————————— 谢谢各位了。

yanqiang zhan:

回复 ChongWen Zhao:

兄弟怎么设置的啊?贴出来看看啊~~~~

赞(0)
未经允许不得转载:TI中文支持网 » 28035 ADC用软件直接触发的问题
分享到: 更多 (0)