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/TMS320F28335: Meaning of AdcRegs.ADCRESULT0 >>4, Data manipulation of ADCRESULT0

Part Number: TMS320F28335
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Tool/software: Code Composer Studio

I found terms like AdcRegs.ADCRESULT0 >>4 in many programmes. I didn't get what is the meaning of  >>4. 

Also please help me on how to manipulate the ADC result data and store?

For Example, I need to subtract the AdcMirror.ADCRESULT0 from FFFF. Hoe to write the code and how to verify the results?

  • Hi Soumya,

    Soumya Ranjan Meher said:
    I found terms like AdcRegs.ADCRESULT0 >>4 in many programmes. I didn't get what is the meaning of  >>4. 

    Its a simple bit right-shift operation. As its a 12-bit ADC, this is the way to convert a 16-bit value to 12-bit one.

    Soumya Ranjan Meher said:
    For Example, I need to subtract the AdcMirror.ADCRESULT0 from FFFF. Hoe to write the code and how to verify the results?

    Store the ADC result value to a variable say 'a' and b = 0xFFFF. c = b-a; You can monitor these 3 variables on expression window while in debug mode.

    Regards,

    Gautam

  • Thank you, Sir. Now my programme is running, but Still, I am unable to track the variables. In the Expression window, when I am typing the name of the variable (say a), it's showing many options in the scroll down menu except "a".
  • Check whether 'a' is a global variable or not. For real-time variable update, it needs to be set as global. Also, very importantly you need to enable 'Continuous Refresh' button on top of expression window.
  • I have followed all the steps. Its working fine with simple programs like addition. But I am unable to store the ADC results value. I have taken

    m = AdcMirror.ADCRESULT0;

    n = AdcRegs.ADCRESULT0;

    Mirror and AdcRegs value are showing correct results but m & n values are showing incorrectly. I am attaching a snapshot with this.

  • Soumya,

    It looks like the while(1) loop in main() will not allow your m and n assignments to execute. That could be the reason for the warning on line 48.

    Also, the value of AdcMirror does not need to be shifted as it is already done in hardware.

    -Tommy
  • Please suggest me the solution. Here is another screenshot without any warning. Though the mirror result0 value showing correctly, the variable a and b are incorrect. Please help me to make the proper way to see the result in a variable so that I can do the mathematical operation with the Adc result.

  • Please suggest me the solution. Here is another screenshot without any warning. Though the mirror result0 value showing correctly, the variable a and b are incorrect. Please help me to make the proper way to see the result in a variable so that I can do the mathematical operation with the Adc result.

  • Hi,

    Its better to check the ADCINT flash before fetching results. Something like this:

    while(1)
    {
      while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){}
      AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; 				//Clear ADCINT1
    
      a = AdcResult.ADCRESULT0;
    }
    		 

    Please do refer: C:\ti\controlSUITE\device_support\f2833x\v142\DSP2833x_examples_ccsv5\adc_soc

    Regards,

    Gautam

  • Sir,
    I am unable to check that. while I inserted this code, the Error message was "struct ADC_REGS has no field ADCINTFLG " also for the next line too.
  • Sir, I have marked one more thing,  that whenever I am subtracting an integer from the ADC result value (say 5), then the result is 65531. (65536-5=65531). 65536 in decimal is equal to 1 0000 in HEX. So, is there any problem regarding 16 bit or 32 bit?

    Another point is, The result remains the same (65531) while ADC A0 pin is connected to 3V3 or GND. I have attached some screenshots with this for reference.

    While connecting to 3v3

    While connecting to GND,

  • Soumya,

    It almost looks as if you are trying to read the results before the ADC is triggered?

    Have you tried running an unmodified ADC example from controlSUITE or C2000Ware? I recommend that you start from a working example and then slowly make edits in your own copy with frequent builds to make sure that everything is working as expected.

    -Tommy