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.

ADC CONFIGURATION

Other Parts Discussed in Thread: CC2530, Z-STACK

Hello Everybody,

I am working with cc2530 device and I want to use Port0's 4 ADC.

I want to work with P0_0,P0_1,P0_2 and P0_3.

To obtain the correct configuration, I have wrote those lines:

    P0DIR = 0;

    P0INP = 0x0f;

    APCFG = 0x0f;

with this configuration, I want to disable pull-ups and pull-downs, and define those pins like a INPUT.

With the first 3 pins (P0_0,P0_1,P0_2) I have not any problem, and I am measuring quite well using this function "HalAdcRead (HAL_ADC_CHANNEL_1, HAL_ADC_RESOLUTION_14);"

The problem is P0_3 pin. When I am measuring I don't obtain any correct value.

Can anybody tell me something to solve this problem?

BR

  • There shouldn't be any difference between P0_3 and the others. The APCFG = 0x0F instruction will ensure that the pins can be used as an ADC input, regardless of the settings of P0DIR and P0INP.

    I think the problem could be in the board or the program. Could you provide some more detail?

  • Hi hec,

    I can give you more information but, what do you want?

    I don't know what to give you!

  • The following information could be useful:

    • The code that you execute.
    • What do you observe and what did you expect to observe
    • Your schematics

    I assume the HalAdcRead function that you are referring to is the one in Z-Stack, right? If so, you don't need any modification of the I/O registers. It will modify the APCFG register for you (the code uses the name ADCCFG, which is an alias for APCFG).

  • The code:

    void Hal_Process( void )

    {

      uint32 adc0 = 0,adc1 = 0,adc2 = 0,adc3 = 0;;

      MeasuresCont++;

      if (MeasuresCont==250)

      {

        P0DIR = 0;

        P0INP = 0x0f;

        APCFG = 0x0f;

        // configuración de la referencia de los ADCs    

        HalAdcSetReference (0x80);//HAL_ADC_CHN_GND

        adc0 = HalAdcRead (HAL_ADC_CHANNEL_0, HAL_ADC_RESOLUTION_14);

        adc1 = HalAdcRead (HAL_ADC_CHANNEL_1, HAL_ADC_RESOLUTION_14);

        adc2 = HalAdcRead (HAL_ADC_CHANNEL_2, HAL_ADC_RESOLUTION_14);

        adc3 = HalAdcRead (HAL_ADC_CHANNEL_3, HAL_ADC_RESOLUTION_14);

        MeasuresCont=0;

        Send_Message (adc3);

        Send_Message (adc2);

        Send_Message (adc1);

        Send_Message (adc0);

      }

    }

    What do you observe and what did you expect to observe:

    I receive the ADC measure in ZTOOL. When I receive the ADC0, ADC1 and ADC2's values, they are correct.

     

    The ADC3 pin is connected to a half power supply voltage. I obtain it with two Megaohm resistors.

    When I receive the ADC3's measure, I receive all the time a very low value, when the power supply is 2.7V.

    What do you think? 

  • Hi,

    There are a couple of problems here. The first is the megaohm resistors. If you look in the data sheet, you will see that the ADC input resistance is listed at 197 kOhm (typically). So this will dominate over your voltage divider and basically pull the input strongly towards ground.

    The second problem is that even if your voltage divider had been adapted to the input resistance of the ADC, you will compare the supply voltage to the supply voltage (unless you use a regulator to supply the chip and no regulator into the voltage divider; in that case your setup is OK). So this will measure VDD/2 with VDD as the reference, always giving 0.5 as the result. I assume what you want to do here is to measure the supply voltage. The recommended way of measuring the supply voltage is to use the internal reference and use ADC channel 15, which is VDD/3. That way you compare the unknown supply voltage to the known reference of about 1.15 V.

  • Hi,

    You are right. I want to do is to measure the supply voltage.

    Can you tell me more about the use of the internal reference and use ADC channel 15?

    Can i obtain the power supply voltage value?