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: TMS320F28377S

Part Number: TMS320F28377S

Tool/software: Code Composer Studio

Hi,

I want to read ADC values and generate digital Output(writing to digital pin and reading from analog pin are done separately and values not related to each other). But whenever I try to read ADC values after writing to digital pins, I am not able to read appropriate values from ADC.

ADC read part works fine when I comment the digital Output part 

Here is the code snippet of my writing to digital pins and reading from ADC pins.

Please suggest any changes to be made for it to work.

PS: do not consider syntax errors as this only a part of the code  

//Code snippet 

void digitalpinInitialize(int gpionumber)
{
GPIO_SetupPinMux(gpionumber, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(gpionumber, GPIO_OUTPUT, GPIO_PUSHPULL);
}

int adcRead(int channel)
{
EALLOW;
switch(channel)
{
case 0: //AA0
case 1: //AA1
case 2: //AA2
case 3: //AA3
case 4: //AA4
case 5: //AA5
case 0xC: //A14
case 0xD: //A15
EALLOW;
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

Uint16 acqps;

AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel; //SOC will convert on channel
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
//1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0; //disable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0;
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 1;
AdcaRegs.ADCINTFLGCLR.all = 0x000F;
AdcaRegs.ADCSOCFRC1.all = 0x00FF;
DELAY_US(5);
return AdcaResultRegs.ADCRESULT0;
}
}

void main(void)

{

digitalpinInitialize(14);

 GPIO_WritePin(14,1); //to write into digital pin 14

AdccResults = adcRead(3); //to read from adc pin 3

}