Tool/software: Code Composer Studio
Helllo Experts,
I'm trying to run ADC code on TMS320F2812 using SYS/BIOS RTOS. i have all pins on channel A (8) ADC working (legacy code). i wanted to sample channel B (8 channels) as part of modifications.
I just made some basic changes to the code & observed that I'm getting expected voltage on ADCINB0 but incorrect values on the rest of channel B.
All the pins on ADCINB1-B7 are not connected to anything in schematic & I have confirmed on the board that the voltage measurement is about 0V. I am reading anywhere between 1.9V to 2.5V (depending on channels), consistently though.
I have gone through the entire ADC module documentation of the uC (ADC_spru060d) but can't seem to understand what could be the issue, can anyone pleasee help me... the configuration of ADC is as below.
- dual sequencer
- start stop type
- sw controlled
code attached.
AdcRegs.ADCTRL1.bit.SUSMOD = 2u; //Sequencer stops after current conversion
AdcRegs.ADCTRL1.bit.ACQ_PS = 0xfu; //16 cycles acquisition window
AdcRegs.ADCTRL1.bit.CPS = 1u; //Divide the HSPCLK by 2
AdcRegs.ADCTRL1.bit.CONT_RUN = 0u; //Start Stop Mode
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1u; //Sequencer override enabled
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0u; //Dual sequencer mode
//ADC CTRL3 Reg Initialization
AdcRegs.ADCTRL3.bit.ADCEXTREF = 1u; //External reference enabled.
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0xfu; //Divide HSPCLK by 30
//ADCMAXCONV Reg Initialization
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x7u; //8 conversion in channel A
AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 0x7u; //8 conversion in channel B
//ADC SEQ1 select register as per REV AD
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0u; //ADCINA0
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 1u; //ADCINA1
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 2u; //ADCINA2
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 3u; //ADCINA3
//ADC SEQ2 select register
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 4u; //ADCINA4
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 5u; //ADCINA5
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 6u; //ADCINA6
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 7u; //ADCINA7
//ADC SEQ3 select register
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 8u; //ADCINB0
AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 9u; //ADCINB1
AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 10u; //ADCINB2
AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 11u; //ADCINB3
//ADC SEQ4 select register
AdcRegs.ADCCHSELSEQ4.bit.CONV12 = 12u; //ADCINB4 N/C
AdcRegs.ADCCHSELSEQ4.bit.CONV13 = 13u; //ADCINB5 N/C
AdcRegs.ADCCHSELSEQ4.bit.CONV14 = 14u; //ADCINB6 N/C
AdcRegs.ADCCHSELSEQ4.bit.CONV15 = 15u; //ADCINB7
//Start Bandgap and reference circuitry. This is placed here to powerup ADC
//after setting the registers.
AdcRegs.ADCTRL3.bit.ADCBGRFDN = 3u;
//7ms gap is required before ADC can be powered on. The below gap is about 10ms
for(iVol= 0; iVol< ( (900000/2)/12 ); iVol++)
{
}
AdcRegs.ADCTRL3.bit.ADCPWDN = 1u;
//20 micro seconds required before conversion starts
for(iVol= 0; iVol< ( (1500/2)/12 ); iVol++)
{
}
//TRIGGER ADC
if( adc_channel == ADC_CHANNEL_A )
{
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1u;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1u;
}
else if( adc_channel == ADC_CHANNEL_B )
{
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1u;
AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 1u;
}