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.

TMS320F280049C: TMS320F280049C

Part Number: TMS320F280049C
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Tool/software:

Hi, 

I am using 56RSH package, with the below code, as suggested I am not using sysconfig

#include "driverlib.h"
#include "device.h"
#include "board.h"

 

// PGA instance for ADCIN2
#define PGA_NUMBER_3 3U

 

void initADC(void);
void initPGA(void);
void initSOC(void);

 

void main(void)
{
    uint16_t adcResult;
    float voltage;

 

    // Initialize device clock and peripherals
    Device_init();

 

    // GPIO setup (not needed for C2 since it's analog-only, but kept for consistency)
    Device_initGPIO();

 

    // Optional: Board init (can be removed if not using Board.c/.h)
    Board_init();

 

    // Enable ADCC
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_ADCC);

 

    // Initialize ADC, PGA, and SOC
    initADC();
    initPGA();
    initSOC();

 

    while (1)
    {
        // Trigger ADC conversion on SOC2
        ADC_forceSOC(ADCC_BASE, ADC_SOC_NUMBER2);

 

        // Wait for conversion to complete
        while (!ADC_getInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1)) {}

 

        // Clear the interrupt flag
        ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);

 

        // Read ADC result
        adcResult = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER2);

 

        // Convert ADC value to voltage (assuming 3.3V ref)
        voltage = ((float)adcResult * 3.3f) / 4095.0f;

 

        DEVICE_DELAY_US(100000);  // Delay for observation (100ms)
    }
}

 

void initADC(void)
{
    // Set VREF to internal 3.3V
       ADC_setVREF(ADCC_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);

 

    // Set ADC clock divider
    ADC_setPrescaler(ADCC_BASE, ADC_CLK_DIV_4_0);

 

 

    // Set EOC to trigger interrupt at end of conversion
    ADC_setInterruptPulseMode(ADCC_BASE, ADC_PULSE_END_OF_CONV);

 

    // Enable ADC converter
    ADC_enableConverter(ADCC_BASE);
    DEVICE_DELAY_US(1000); // Delay for ADC stabilization
}

 

void initPGA(void)
{
    // Enable PGA3 (attached to ADCIN2)
    PGA_enable(PGA3_BASE );

 

    // Set gain to 3x (choose PGA_GAIN_3, _6, or _12)
    PGA_setGain(PGA3_BASE , PGA_GAIN_3);
}

 

void initSOC(void)
{
    // Configure SOC2 on ADCC to sample from ADCIN2 (via PGA3)
    ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER2,
                 ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN2, 14);

 

    // Link interrupt 1 to SOC2 EOC
    ADC_setInterruptSource(ADCC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER2);
    ADC_enableInterrupt(ADCC_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);
}

Now, the voltage is not coming as expected in custom board.