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.

CC1310: Read analog value from specific PIN in sensor example

Part Number: CC1310

Hi,

my software is based on the sensor example from the Simplelink SDK 1.50. Now I want to transmit the battery voltage to the collector. The battery is connected to PIN 30.

My problem is, that I couldn't find where I can specify what PIN should be read during ADC.

Can anyone give me an example?

  • Try to refer to ADC example at dev.ti.com/.../
  • Also in the adc example, I cannot find the assignment of a specific pin. There are ADC BufNames, ChannelNames and ADCNames. The code just
    uses a ADCName for ADC_open with default params.
  • You have to revise "adc = ADC_open(Board_ADC0, &params);" to do it.
  • The input is selected by:
    adc = ADC_open(Board_ADC0, &params);

    Board_ADC0 is mapped as follows:

    #define Board_ADC0 CC1310_LAUNCHXL_ADC0

    CC1310_LAUNCHXL_ADC1 is defined as a enum:

    typedef enum CC1310_LAUNCHXL_ADCName {
    CC1310_LAUNCHXL_ADC0 = 0,
    CC1310_LAUNCHXL_ADC1,
    CC1310_LAUNCHXL_ADC2,
    CC1310_LAUNCHXL_ADC3,
    CC1310_LAUNCHXL_ADC4,
    CC1310_LAUNCHXL_ADC5,
    CC1310_LAUNCHXL_ADC6,
    CC1310_LAUNCHXL_ADC7,
    CC1310_LAUNCHXL_ADCDCOUPL,
    CC1310_LAUNCHXL_ADCVSS,
    CC1310_LAUNCHXL_ADCVDDS,

    CC1310_LAUNCHXL_ADCCOUNT
    } CC1310_LAUNCHXL_ADCName;

    Then in CC1310_LAUNCHXL.c:

    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCCOUNT] = {
    {
    .adcDIO = CC1310_LAUNCHXL_DIO23_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO7,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO24_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO6,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO25_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO5,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO26_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO4,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO27_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO3,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO28_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO2,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO29_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO1,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = CC1310_LAUNCHXL_DIO30_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO0,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_DCOUPL,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_VSS,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_VDDS,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
    .returnAdjustedVal = false
    }
    };

    which defines the physical pins.
    So if I don't count wrong you need to add:
    #define Board_ADC7 CC1310_LAUNCHXL_ADC7

    to get DIO30.
  • Ah, I see. The ADC configuration in the CC1310_LAUNCHXL.c is completly missing in the sensor example. So I will copy it from the adc example. So ADC7 should be mapped to DIO30.
  • I added all the config to the sensor project and renamed the defines to fit the sensor example defines. Now I have the problem, that my adcHandle is always NULL. Is there a known issues what causes this?
  • Exactly which example did you start from for which development board?
  • I use the Sensor Example (C:\ti\simplelink_cc13x0_sdk_1_50_00_08\examples\rtos\CC1310_LAUNCHXL\ti154stack\sensor) and want to extend it with ADC on Pin30. The ADC Config was missing, so I copyed it from the adcsinglechannel_CC1310_LAUNCHXL_tirtos_ccs project taken from the Resource Explorer for the SDK 1.50.

    I use a selfmade board what is compatible to the CC1310 Launchpad but is extended with a Display.

    Right now, I call ADC_init() from main. I added a function to the SSF which opens, reads and closes the adc, just like the threadFxn0 from the adcsinglechannel example. I call my ADC function when I process a button press in SSF_processEvents. So it is called from task context and after the bios is started.

  • I have not looked at the stack so not sure if that defines the ADC somewhere else. One thing I noted when looking at the board file is that DIO30 is defined (you can remove this line)
  • It seems to work now. I removed all other definitions for Pin30. I also tryed the CC1310_LAUNCHXL_ADCVDDS and didn't noticed that it was working, because the Debugger showed the Handle as NULL, but it wasn't. And the ADC seems to be always 100-120mV too low.
  • Do you do a adcValue0MicroVolt = ADC_convertRawToMicroVolts(adc, adcValue0); as done in the adcsinglechannel example?