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.

Strange values from ADC in cc2650

Other Parts Discussed in Thread: CC2650, CC2640

Hi

I am using SensorTag cc2650 hardware and CCS, and I am trying to read values from ADC. But, I get strange values. For testing I am trying to read pin DIO_30, that is tied to VDD. This is illustrated in the clip below.

I am using my own software and have changed the standard Board.c and Board.h file, and initiate the GPIO like this:

// Anlog input
#define Board_Flow_ADC_Pin IOID_30

PIN_Config BoardGpioInitTable[] = {
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
Board_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */
PIN_TERMINATE
};

PIN_Config flowPins[] = {
Board_Flow_ADC_Pin | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS ,
PIN_TERMINATE
};

At start I initiate the pin:

m_flowPinHandle = PIN_open(&m_flowPinState, flowPins);

I am reading the ADC values in the loop by this code:

// Enable clock for ADC digital and analog interface (not currently enabled in driver)
	// This is for starting the Sensor Controller (AUX) - AL
	AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);

	// Connect AUX as analog input.
	AUXADCSelectInput(Board_Flow_ADC_Pin);

	// Set up ADC
	AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);

	// Disallow STANDBY mode while using the ADC.
	Power_setConstraint(Power_SB_DISALLOW);

	// Trigger ADC sampling
	AUXADCGenManualTrigger();

	// Pop sample from FIFO
	//  Note that the first conversion may be invalid if the sampling period is too short.
	uint32_t singleSample = AUXADCReadFifo();  // Throw away first ?

	AUXADCGenManualTrigger();
	singleSample = AUXADCReadFifo();

	// Disable ADC
	AUXADCDisable();

	// Allow STANDBY mode again
	Power_releaseConstraint(Power_SB_DISALLOW);

I am expecting singleSample in the range of 3.3V/4.3V * full range (4096) -> 3143. The values I am reading is around 543 (decimal).

Is this correct. Am i doing anything wrong here?
What should I expect?
Is the value signed?

Regards Arne

  • Hi Arne,

    I suspect you are measuring on a floating pin and not the one you intend to.
    The function AUXADCSelectInput takes one of the following arguments as described in the doxygen documentation:

    ADC_COMPB_IN_VDD1P2V
    ADC_COMPB_IN_VSSA
    ADC_COMPB_IN_VDDA3P3V
    ADC_COMPB_IN_AUXIO7
    ADC_COMPB_IN_AUXIO6
    ADC_COMPB_IN_AUXIO5
    ADC_COMPB_IN_AUXIO4
    ADC_COMPB_IN_AUXIO3
    ADC_COMPB_IN_AUXIO2
    ADC_COMPB_IN_AUXIO1
    ADC_COMPB_IN_AUXIO0

    Pins in the AUX domains are mapped to AUX IOs (and not DIOs) so after disabling input/output buffers on DIO30 you need to connect AUXIO0 to the ADC itself. The mapping between DIO's and AUX IO's are found in "Chapter 11.8 I/O Pin Mapping" in the technical reference manual (SWCU117).

    Regards,
    Svend
  • Hi Svend

    Thanks for answer.

    I have changed to AUXADCSelectInput(ADC_COMPB_IN_AUXIO0); as you proposed.

    Now I am getting more sensible values, but there is one more thing that worries me.

    Since I am using AUXADC_REF_FIXED as reference, I expect the value 4095 to represent 4,3 V (as mentioned in the documentation). DIO_30 are connected directly to VDD (battery), and I am getting 2610 as a value from ADC. Calculation of the voltage should then be (2610*4,3V)/4095. That gives 2.74V, representing the voltage on the battery.

    When I am using the battery service that you provide in your examples (without modifications), I get a reading of 90%. In your calculations of the percentage you have used 3.273V as max. value. Then 90% should be  2.95V.

    Do you have any idea why this two values are different?

    Are the value I am getting from ADC as I could expect?

    Regards Arne

  • Hi Arne,

    The RAW ADC conversions are not compensated for ADC gain and offset error. If you use TI RTOS >= 2.13.00.06 you have some more functionality in there to compensate your measurements:

    AUXADCGetAdjustmentGain - Read out gain error from TI Factory config page
    AUXADCGetAdjustmentOffset - Read out offset error

    AUXADCAdjustValueForGainAndOffset - Returns corrected conversion value.

    As far as I know the battery service do not use the ADC but the internal always on battery monitor which has an accuracy in the 50-70mV range. That service has defined 3273 mV as 100% but you are free to define another max that suits your product.

    Note that the BLE stack 2.0.0 battery service re-configures the battery monitor using AONBatMonMeasurementCycleSet. This function should not be called and is removed in the next version of the BLE stack (you should also remove it from your implementation).

    Regards,
    Svend

  • Hi Svend
    Thanks for the clarification!
    Regards Arne
  • i can't found the "doxygen documentation", and I can't understand the how to use those macro:ADC_COMPB_IN_VDDA3P3V, ADC_COMPB_IN_VSSA and ADC_COMPB_IN_VDD1P2V,
    do you know?
  • Hi Arne,

    I am a fellow SensorTag CC2650 user. What software/hardware are you using to display your ADC values?

    And is the code that you have attached above used in CCS? May I please know where you learnt this codes? I am unable to find a document that teaches me the definitions of the codes and how it can be used.

    Thanks.

    From,
    Chelsia
  • You can try to output ADC reading by UART.
  • why should we disallow standby mode while using standby
  • Sorry, don't understand your question well. Can you elaborate?
  • You want the ADC to run on 48MHz clk then you need to disable standby in order to make sure the system is running on that clk
  • I got quite a similar issue, my ADC is configured with fixed voltage 4.3V.

    When input in range [0, 3.7] I get some precise ADC measures corresponding to input voltage.

    Above I get some invalid results, ADC gain seems different e.g :

    3561 (corresponding to 3.73V) read on ADC for an input value of 3.87V

    3581 (correspondig to 3.76V) raed on ADC for an input value of 4.16V


    I've adjusted results and configured ADC with :

      // Set up ADC - 4.3V reference
      AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
    
      // Disallow STANDBY mode while using the ADC.
      Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    
      AUXADCGenManualTrigger();
    
      /** Wait read completion using Mutex */
      Semaphore_pend(_hReadMutex, BIOS_WAIT_FOREVER );
    
      /** Adjust measure */
      _u16_lastRead = AUXADCAdjustValueForGainAndOffset(_u16_lastRead,
          AUXADCGetAdjustmentGain(AUXADC_REF_FIXED),
          AUXADCGetAdjustmentOffset(AUXADC_REF_FIXED));

    How can I solve it?

  • Lahorde,

    What is your supply voltage when testing this? If you connect a voltage higher than the supply voltage you possibly trigger the ESD diodes so the voltage will actually be lower.

    The gain/offset adjustment is done as a linear approximation so it should track just fine also above 3.7V.
  • Svendbt,
    I think you are true. On CC2640 I cannot read any voltage > VDDS max = 3.8V. But I do not understand this 4.3V adc reference. The ADC automatically scales down the input signal to be within the reference range, so, for signal above 4.3V I will get a 4.3V scaling. But if analog input max voltage = 3.8V , what is the point of having a 4.3V ADC voltage reference?
  • Analog input max is <= VDDS, whatever VDDS is. The reason for the ADC supporting up to 4.3V is that the device was initially designed to support this voltage - unfortunately it was not possible to have the entire device support 4.3V so the maximum supply voltage is limited to 3.8V.

    Regards,
    Svend