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.

Sampling 2 channels of the ADC of C5535

Other Parts Discussed in Thread: TMS320C5535

Hi all,

I have a TMS320C5535 eZdsp board. I am completely new to this board and I was wondering how should I go about it ? Any sample code about ADC would help. I would like to sample one channel store the value and then sample other channel and store that value as well. I looked into the datasheet, but I didn't find much info on how to get started with ADC. 

  • Hi,

    For details on the SAR module refer to C5535 TRM SPRUH87D  chapter 11.

    Their exists SAR related examples in C55xx CSL (3.04) pacakege, you can download and install C55xx CSL package from the below link.

    http://www.ti.com/tool/sprc133

    Also, eZDSP related technical refence manual,schematics etc is available in the below mentioned spectrum digital link.

    http://support.spectrumdigital.com/boards/ezdsp5535/revc/

    Hope the above information helps you to proceed further.

    Regards

     Vasanth

  • Hi,

    Thanks for the reply. I already have the low power package installed when I installed Code composer studio. And so how do I see the examples in a particular package ?

  • Hi,

      Once you install the CSL 3.04 package, you will be able to find SAR CSL examples files in the path:

      <>\c55_lp\c55_csl_3.04\c55xx_csl\ccs_v5.0_examples\sar

     Also, respective readme file exists in

     <>\c55_lp\55_csl_3.04\c55xx_csl\ccs_v5.0_examples\Readme's_for_existing_examples

    Hope this helps

    Regards

     Vasanth

     

  • Thanks actually i did not had that package initially..In the example there are various functions being used..like SAR_startConversion, SAR_stopConversion. So where are these functions defined ?
  • Hi,

      you can find this in src folder - <>\c55_lp\c55_csl_3.04\c55xx_csl\src

      Also, all these are part of CSL package and if you try to grep,should be able to find it.

      Hope this helps.

    Regards

     Vasanth

  • Hi,

    Thanks for the reply. The examples are quite difficult to understand. I had one question -

    Which are the input pins for the SAR ADC ? GPAIN3 - 0 right ? How do I set a particular pin as input ? I am not able to understand which bits of SARGPOCTRL I should modify ? Like if I want to set GPAIN1 as input for ADC should I make bit 3 of SARGPOCTRL register 1 and rest all bits 0 ? Could you explain SARGPOCTRL register's last 4 bits ?  

  • Also I want to sample the ADC continuously rather than on an interrupt...So how would you suggest that ?
  • Hi,

    My inputs for your questions on SAR:

    GPAIN pins : The device's GPAIN[3:0] pins can be configured as inputs to the SAR ADCs or they can be configured as general-purpose outputs that can be driven high or low (excluding GPAIN0 that can only be driven low). The SAR inputs can be used for battery measurement, internal voltage measurement, volume control, and touch screen control. GPAIN[0] is capable of accepting analog input voltage from 0 V up to 3.6 V while GPAIN[1:3] can accept a range of 0 V to VDDA_ANA.

    Interrupts: The SAR peripheral generates DSP interrupts every time an ADC conversion is completed and data is available to be read by the DSP.

    Continuous conversion: For continuous conversion set Single Conversion mode to 0 this Continuously perform back-to-back conversions, as long as ADCSTRT is set.

    All the details that you are looking for is mentioned in the Technical reference manual. Suggest you to go through this.

    Regards

     Vasanth

  • Hi,

    Thanks for the reply. Your explanation for GPAIN pins is exactly same as in the reference pdf which I had read, but still it was not clear for me. I can figure that out I suppose. One other question I had was like I said I want to sample one channel wait for the conversion, store it and then sample another channel, wait for the conversion, store it and then this should go on. So my doubt is how do I switch between 2 channels ? Do I keep on calling my initialization routines for both channels in a while 1 loop ? I came up with something like this -

    int main(void) {
    unsigned long i;
    unsigned long value[SIZE];
    while (1){

    ADC_init_ch1();
    SARCTRL |= 0x8000; 
    while (SARDATA &= 0x8000)
    {};
    if(i < SIZE){
    value[i] = (SARDATA &= 0x03FF);
    i++;

    ADC_init_ch2();

    SARCTRL |= 0x8000; 

    while (SARDATA &= 0x8000)
    {};
    if(i < SIZE){
    value[i] = (SARDATA &= 0x03FF);
    i++;

    return 0;
    }
    }
    }

    ADC_init_ch1 and ADC_init_ch2 are defined in other file. 

  • Below are the response for questions.

    All 4 GPAIN pins can be set as Inputs. To set the pin to be input, clear (configure to ‘0’) the GPOxEN bit in the SARGPOCTRL register – this will disable the output driver.

    With respect to Switching between channels - As you would have configured GPAIN as input you need not configure this again. Here channel selection through CHSEL select bit in SAR A/D register and controlling ADC start bit is required. So basically you need to select channel and control start bit to start and sample ADC Busy to check for conversion completion. Rest of the configuration need not change (once correctly configured). ADCBUSY bit in the SARDATA register is set to 0, the SAR A/D Data Register contains the channel converted in the CHSEL bit field and the actual converted value in the ADCDAT bit field.

     If interrupts are enabled then SAR peripheral generates DSP interrupts every time an ADC conversion is completed and data is available to be read by the DSP.

     Hope this information helps.

     Regards

     Vasanth