Other Parts Discussed in Thread: C2000WARE
Hello,
i'm trying to sample from ADC and make it trigger from cpu timer 0, but it just doesn't want to to start conversion on pin A2. Here are the configuration functions:
__interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
void ConfigureADC(void)
{
EALLOW;
//
//write configurations
//
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
//
//Set pulse positions to late
//
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
//
//power up the ADC
//
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
//
//delay for 1ms to allow ADC time to power up
//
DELAY_US(1000);
EDIS;
}
void SetupADC_TINT(Uint16 channel)
{
//
//Select the channels to convert and end of conversion flag
//
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A2
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is 100 SYSCLK cycles - 12bit
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //trigger on CPU Timer 0
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;
}
interrupt void adca1_isr(void)
{
//DAC_PTR[dac_num]->DACVALS.all = AdcaResultRegs.ADCRESULT0;
stejt = AdcaResultRegs.ADCRESULT0;
//stejt = 4000;
}
EDIT
I've changed AdcaRegs.ADCSOC0CTL.bit.CHSEL to 2 and stejt = AdcaResultRegs.ADCRESULT2; but there is still nothing in variable stejt even after i apply 3.3v to the a2 pin