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.

TMS320F28377S: Trouble understanding ADC code

Part Number: TMS320F28377S

I am trying to build my own application to read in sensor data through my launchpads ADC-A. I understand all of the example code except for the following:

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared

My question is how come the code only defines behavior for what happens at the end of SOC1? Why is nothing done with SOC0? My code will only use one channel, so I'm not sure if I need to include the latter code that deals with the INT1 flag. Any help would be appreciated.

  • Nikhil,

    You do not say where this code comes from, but I assume both SOC0 and SOC1 have the same trigger.  There will be other code lines which determine that.  In that case, SOC0 will complete first, then SOC1, then you get the interrupt flag so the ISR code can go get both results.

    If you only want to use one channel you can dispense with the SOC0 trigger and set SOC1 to sample the channel you want.  Everything else would remain the same.

    Regards,

    Richard

  • Richard,

    This code comes from the "adc_soc_software_cup01" example, specifically, from the SetUpADCSoftware() function. Let me see if I understand this correctly. From your explanation, it seems like SOC0 has a higher priority than SOC1, i.e the hardware will read in data on channel 0 before channel 1 therefore the code only needs to check for the interrupt flag from SOC1?

    Thanks,

    Nikhil

  • Nikhil,

    Correct.

    Line 129 in that file asserts SOC0 and SOC1 together:
    AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1

    Regards,

    Richard
  • Thank you for your help Richard.