Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
I am building the base control platform using the F28027PPT and evaluating using the F2802xx controlcard with dokking station.
I can power up the adc and link the ADC interrupt to the Epwm without any issue, and i have checked that it is sampling with the correct frequency. I have a potmeter connected to 3V3 and GND and output connected to A1
My problem is the value read in the ADCRESULT.ADCRESULT1 register does not change even though i can measure with an oscilloscope that the input voltage on A1 is changing?
Am i misunderstanding section 6.11.1 in TMS320F2802x,TMS320F2802xx Piccolo - Technical Reference Manual ?
Find my initialization and result reading function below:
ADC initialization:
void SetupADC(void){
EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select internal BG
EDIS;
DELAY_US(1000L);
//Select the channels to convert and end of conversion flag
EALLOW;
//Setup channel direction
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // internal bandgap used for reference
AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; // VrefLO internally connected to ADC Sampling
// ADC setup meassurement
AdcRegs.SOCPRICTL.bit.SOCPRIORITY = 3; // ADC0-2 has high priority
AdcRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin A2
AdcRegs.ADCSOC0CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC0 will convert pin A3
AdcRegs.ADCSOC1CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.ADCCTL1.bit.TEMPCONV = 1;
AdcRegs.ADCSOC2CTL.bit.CHSEL = 5; //SOC0 will convert pin A4
AdcRegs.ADCSOC2CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
AdcRegs.INTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;
}
ADC interrupt function:
interrupt void adca1_isr(void)
{
//DINT;
//a = (double)AdcaResultRegs.ADCRESULT0*Vx + Vy;
Global.DataReady = 1;
ADC_TOGGLE();
a = AdcResult.ADCRESULT1*(3.3/4095);
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Allow other interrupts from group 1
// EINT;
}