Greetings.
Recently, I try to trigger ADC start of conversion via software seting flags, however, there might be something
wrong with my ADC setup so that it could not start properly as I wish.
AdcRegs.ADCSOCFRC1.bit.SOC0 is stil zero even though I set it to 1.
Here is my code----------------------------------------------------
-------start of code(only code related to 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 interrupts
DINT;
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;
} ---------------------------------------------------------------------- -----------------end of code--------------------------------------- ---------------------------------------------------------------------- Is there something I could do to start ADC ? I would be glad, if someone could give me a hand. JOE Chao