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.

RTOS/CC2640: Read ADC value from an Analog capable pin

Part Number: CC2640
Other Parts Discussed in Thread: CC2650

Tool/software: TI-RTOS

Hello E2E experts and friends, 

Our custom board (based on CC2640) have a BATT_MON connected to pin IO_29, its schematic is as follow,

Our board is powered by a 3.7V battery and it is running off a regulator, so it’s unable to use TI internal battery moniror AONBatMonBatteryVoltageGet. The BATT_MON is on an analog capable pin (DIO29), so I assume it would be able to read the value on that pin. We want to add this to monitor the battery voltage to save/synchronize the progress in our project. Is there any simple code snipset I could follow to achieve this (I have no experience with adc reading). What changes would I have to make in CC2650_LAUNCHXL.h, .c, Board.h to make it to work?

Thanks,

Henry

  • Hello Henry,

    Have you looked at the adc examples in the TI-RTOS 2.20 installation?
    C:\ti\tirtos_cc13xx_cc26xx_2_20_01_08\examples\TI\CC2650_LAUNCHXL\adc*

    Best wishes
  • Thank you JXS,

    I did a search on forum and found a couple post mentioned that project, but my CCS has error on showing the resource explorer (and I did not reinstall the CCS yet). Is there any other sources that I can find that project?

    Thanks,
    Henry
  • Try to access resources explore from http://dev.ti.com/tirex/#/
  • Thank you JXS and Yikai for your response.

    Just one last question before closing this post: In the adcsinglechanel project, the program read the adc from main:

        adc = ADC_open(CC2650_LAUNCHXL_ADCVSS, &params);
        //or adc = ADC_open(CC2650_LAUNCHXL_ADCVDDS, &params);
    
        if (adc == NULL) {
            System_abort("Error initializing ADC channel 0\n");
        }
        else {
            System_printf("ADC channel 0 initialized\n");
        }
    
        /* Blocking mode conversion */
        res = ADC_convert(adc, &adcValue0);

    I think this code segment tries to read the ADC value from CC2650_LAUNCHXL_ADCVSS or CC2650_LAUNCHXL_ADCVDDS, these ADCs are also in enum of ADCs in CC2650_LAUNCHXL.h,

    /*!
     *  @def    CC2650_LAUNCHXL_ADCName
     *  @brief  Enum of ADCs
     */
    typedef enum CC2650_LAUNCHXL_ADCName {
        CC2650_LAUNCHXL_ADC0 = 0,
        CC2650_LAUNCHXL_ADC1,
        CC2650_LAUNCHXL_ADC2,
        CC2650_LAUNCHXL_ADC3,
        CC2650_LAUNCHXL_ADC4,
        CC2650_LAUNCHXL_ADC5,
        CC2650_LAUNCHXL_ADC6,
        CC2650_LAUNCHXL_ADC7,
        CC2650_LAUNCHXL_ADCDCOUPL,
        CC2650_LAUNCHXL_ADCVSS,
        CC2650_LAUNCHXL_ADCVDDS,
        CC2650_LAUNCHXL_ADCCOUNT
    } CC2650_LAUNCHXL_ADCName;

    So, in my particular case, if I want to read ADC value from DIO_29, the ADC in the first code segment should be change to CC2650_LAUNCHXL_ADC6, is it correct? 

    Thank you,

    Henry

  • Yes. If you want to read ADC value from DIO_29, the ADC in the first code segment should be change to CC2650_LAUNCHXL_ADC6.