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.

CCS/TMS320F28377S: C2000

Part Number: TMS320F28377S


Tool/software: Code Composer Studio

Hi All,

I am using TMS320F28377S for my application, in that i need to use ADC.

I tried with example in C2000 ware. Code build without any error and it will loaded to My launchpad, the program runs without any problem.

Only one thing is ADC results remains zero, when applied 2V to ADCchannel 0 and 1(Launch pad pins 28, 30 in J3).

Help to me to resolve this.

Yuvaraj.

My code below


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


//
// Defines
//
#define EX_ADC_RESOLUTION ADC_RESOLUTION_12BIT // Or ADC_RESOLUTION_16BIT
#define EX_ADC_SIGNAL_MODE ADC_MODE_SINGLE_ENDED // Or ADC_MODE_DIFFERENTIAL

// Globals
uint16_t adcAResult0;
uint16_t adcAResult1;
uint16_t adcBResult0;
uint16_t adcBResult1;
uint16_t sDataA[10];
uint16_t rDataA[10];
uint16_t rDataPointA;
uint16_t a,j;

uint16_t AdcaResults[10];
uint16_t resultsIndex;


// Function Prototypes

void initADCs(void);
void initADCSOCs(void);


void main(void)
{
Device_init();
Device_initGPIO();
Interrupt_initModule();
Interrupt_initVectorTable();
initADCs();
initADCSOCs();
EINT;
ERTM;

while(1)
{
for(j = 0; j < 10000; j++)
{
for(a = 0; a < 100; a++)
{

}
}

// Convert, wait for completion, and store results
ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0);
ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER1);

while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1) == false)
{
}
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

// Store results
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);

for(j = 0; j < 10000; j++)
{
for(a = 0; a < 100; a++)
{

}
}
}
}


// Function to configure and power up ADCs A and B.
void initADCs(void)
{
// Set ADCCLK divider to /4
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);

// Set resolution and signal mode (see #defines above) and load corresponding trims.
ADC_setMode(ADCA_BASE, EX_ADC_RESOLUTION, EX_ADC_SIGNAL_MODE);

// Set pulse positions to late
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);

// Power up the ADCs and then delay for 1 ms
ADC_enableConverter(ADCA_BASE);

//DEVICE_DELAY_US(1000);
for(j = 0; j < 1000; j++)
{
for(a = 0; a < 100; a++)
{

}
}
}

// Function to configure SOCs 0 and 1 of ADCs A and B.
void initADCSOCs(void)
{
// Configure SOCs of ADCA
// - SOC0 will convert pin A0.
// - SOC1 will convert pin A1.
// - Both will be triggered by software only.
// - For 12-bit resolution, a sampling window of 15 (75 ns at a 200MHz
// SYSCLK rate) will be used. For 16-bit resolution, a sampling window
// of 64 (320 ns at a 200MHz SYSCLK rate) will be used.
#if(EX_ADC_RESOLUTION == ADC_RESOLUTION_12BIT)
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY,
ADC_CH_ADCIN0, 15);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_SW_ONLY,
ADC_CH_ADCIN1, 15);
/*#elif(EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT)
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY,
ADC_CH_ADCIN0, 64);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_SW_ONLY,
ADC_CH_ADCIN1, 64);*/
#endif

// Set SOC1 to set the interrupt 1 flag. Enable the interrupt and make sure its flag is cleared.
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

}

  • Hi Yuvaraj,

    I do not see anything off from your code except for the use of the nested loops which I assume were added for debug purposes only. We strongly recommend to use the built-in delay function calls as these give more accurate time base. You mentioned that you used launch pad pins 28 and 30 for ADCA channels 0 and 1. Launchpad pin 28 corresponds to ADCB ch0 and pin 30 is no connect. Since you are using ADCA channels 0 and 1 on your code, you might want to use Launchpad pins 27 and 29 respectively.

    Regards,
    Joseph
  • Thank you Joseph. I got result now