This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F28379D: Change of value of ADC Reading

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Hello,

I'm trying monitor my ADC reading of my software at the Watch Window at the right upside corner of the CCS.

Although I apply a DC stable voltage to ADC Input, the reading of ADC that is seen at the window has some much variation. My ADC configuration is as below. How can I solve it? 

I tried to configured Epwm3 for soc and it checks ADC result at a frequency of 5kHz, if my code is correct?.

"""""""""""""""""""""""""""""""""""""""""""

// Function Protoypes
//

void ConfigureADCa3(void);

void ConfigureEPWMb3(void);

void SetupADCEpwma3(void);

interrupt void adcb3_isr(void); 

//
//=====================================
// ADCINA3-Vout Variables
//
float Vout_real=0, Vout_ADC=0;

// Configure the ADC and power it up
ConfigureADCa3();

// Configure the ePWM
ConfigureEPWMb3();

// Setup the ADC for ePWM3 triggered conversions on channel 0
SetupADCEpwma3();

void ConfigureADCa3(void)
{
EALLOW;
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADCCLK divider to /4
AdcaRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0; // Single-ended channel conversions (12-bit mode only)
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC A
DELAY_US(1000); // Delay for 1ms to allow ADC time to power up
EDIS;
}

void ConfigureEPWMb3(void)
{
EALLOW;
// Assumes ePWM clock is already enabled
EPwm3Regs.TBCTL.bit.CTRMODE = 0; // Freeze counter
EPwm3Regs.TBPRD = 20000; // Set period to 20000 counts (5kHz ??)

EPwm3Regs.TBCTL.bit.PHSEN = 1; // Enable phase loading
EPwm3Regs.TBPHS.bit.TBPHS = phaseOffset3; // Phase
EPwm3Regs.TBCTR = 0x0000; // Clear counter
EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0; // TBCLK pre-scaler = /1

EPwm3Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
EPwm3Regs.ETSEL.bit.SOCASEL = 2; // Select SOCA on period match
EPwm3Regs.ETSEL.bit.SOCAEN = 1; // Enable SOCA
EPwm3Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event

// Below codes creates ISR for CNTL_ISR where duty at 0.1 FOR 5kHz
EPwm3Regs.CMPB.bit.CMPB= 1000; // ISR trigger point
EPwm3Regs.ETSEL.bit.INTSEL = 0x6; // INT on CompareB-Up event
EPwm3Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm3Regs.ETPS.bit.INTPRD = 0x1; // Generate INT on every 1st event
EDIS;

void SetupADCEpwma3(void)
{
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 3; // SOC0 will convert pin A3 for ADC A
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; // Sample window is 100 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 9; // Trigger on ePWM3 SOCA (ePWM3A will trigger)

AdcaRegs.ADCINTSEL3N4.bit.INT3SEL = 0; // End of SOC0 will set INT3 flag for ADC A
//ADCINT3 EOC Source Select, if 0h EOC0 is trigger for ADCINT3
AdcaRegs.ADCINTSEL3N4.bit.INT3E = 1; // Enable INT3 flag
AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 0x0F; /* SOC0 has HIGHEST Priority*/
EDIS;
}

interrupt void adca3_isr(void) /**** OUTPUT VOLTAGE ADC ISR ****/
{

/* Buck_Vout_ADC shows real voltage at ADC Input */
Vout_ADC = ( ((float) AdcaResultRegs.ADCRESULT0 / 4096) * 3.3 );

/* Buck_Vout_real shows real Iavg value like 2A */
Vout_real = ((Vout_ADC * 16.3) / 3.3);


if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT3)
{
AdcaRegs.ADCINTOVFCLR.bit.ADCINT3 = 1; //clear INT1 overflow flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; //clear INT1 flag
}
// Return from interrupt
AdcaRegs.ADCINTFLGCLR.bit.ADCINT3 = 1; // Clear ADC INT3 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10; // Acknowledge PIE group 10 to enable further interrupts
}

  • gG said:
    I'm trying monitor my ADC reading of my software at the Watch Window at the right upside corner of the CCS.

    Although I apply a DC stable voltage to ADC Input, the reading of ADC that is seen at the window has some much variation. My ADC configuration is as below. How can I solve it? 

    I tried to configured Epwm3 for soc and it checks ADC result at a frequency of 5kHz, if my code is correct?.

    I recommend debugging with the adc_soc_epwm example from C2000Ware (~\C2000Ware_XXXX\device_support\f2837xd\examples\cpu1\adc_soc_epwm).

    This will help you determine if the issue is with the software or hardware. For example, if the problem persists with the unmodified example, then it is likely a hardware setup issue.

  • Hello,

    I compared by debugging my code and the example code at c2000 folder that you addressed.

    My ADC pin is 26 (ADCINA3), C2000 example ADC pin is 30 (ADCINA0).

    I directly connected 3.3V on the board to pin 26 while my software running and again same 3.3V to pin 30 ADCINA0 while c2000 software running and both are showed 4095 value at AdcaResultRegs.ADCRESULT0 ...

    Then,

    I connected GND to both, my code showed a value between 4 - 14. However, c2000 code showed 0. (It is different but pin by pin change the value may change?)

    I connected a potentiometer between 3.3V and GND and stop a point. The c2000 example code value varies between 1847 and 1865, however my code value varies between 1905 and 1916.

    Do you think that everything is normal in my code by comparing the results?

  • gG,

    From a high level, your results seem reasonable for a LaunchPad prototyping setup. I suspect that a cleaner signal source with high-bandwidth buffering would give you tighter codespread. However, there will always be some amount of variation in the conversions due to inherent component noise.

    Yes, some variation between channels is expected:

    -Tommy