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: Sensor Controller Studio: Configure analog input pins programatically?

Part Number: CC1310

Hi,

I'm developing for a CC1310 and I'd like my application to control which analog input pins are used by the sensor controller rather than configuring statically in sensor controller studio. Is the following the best way to do that? I'm particularly unsure about selecting dummy pins and overriding scifDriverSetup.  My code is based on rfWsnNode_CC1310_LAUNCHXL_tirtos_ccs. I'm running CCS 10.4.0.00006 and Sensor Controller Studio 2.8.0.170.

  1. In Sensor Controller Studio:
    1. Under 'task resources', I check 'Analog pins' and select '2 (accessed by lookup table)'.
    2. Under 'I/O Mapping' I pick two dummy pins to make the sensor compiler happy. They will be ignored during initialization (see below).
    3. Under 'Constants and Data Structures" I add two variables to 'cfg', called analogId1 and analogId2
    4. Under 'Execution code', I select the pins using code like 'adcSelectGpioInput(cfg.analogId1)'
  2. In my application
    1. I override scifDriverSetup (by copying and modifying) to use my own versions of scifTaskResourceInit and scifTaskResourceUnInit My substituted functions call scifInitIo() with the pins I wish to configure as analog input.
    2. I set the cfg fields to pass the same analog input ids to the sensor execution code.

So the relevant section of sensor controller initialization looks like (using #define to specify the analog pins):

static void j_scifTaskResourceInit(void) {
    scifInitIo(E70_ANALOG_ID1, AUXIOMODE_ANALOG, -1, 0);
    scifInitIo(E70_ANALOG_ID2, AUXIOMODE_ANALOG, -1, 0);
}
static void j_scifTaskResourceUninit(void) {
    scifUninitIo(E70_ANALOG_ID1, -1);
    scifUninitIo(E70_ANALOG_ID2, -1);
}
SCIF_DATA_T j_scifDriverSetup;

void SceAdc_init(uint32_t samplingTime, uint16_t adcThreshold) {
    scifOsalInit();
    scifOsalRegisterCtrlReadyCallback(ctrlReadyCallback);
    scifOsalRegisterTaskAlertCallback(taskAlertCallback);
    memcpy(&j_scifDriverSetup, &scifDriverSetup, sizeof(scifDriverSetup));
    j_scifDriverSetup.fptrTaskResourceInit = j_scifTaskResourceInit;
    j_scifDriverSetup.fptrTaskResourceUninit = j_scifTaskResourceUninit;
    scifInit(&j_scifDriverSetup);
    scifStartRtcTicksNow(samplingTime);

    SCIF_ADC_SAMPLE_CFG_T* pCfg = scifGetTaskStruct(SCIF_ADC_SAMPLE_TASK_ID, SCIF_STRUCT_CFG);
    pCfg->analogId1 = E70_ANALOG_ID1;
    pCfg->analogId2 = E70_ANALOG_ID2;
}

Thanks for any comments! I'm wondering about the override that I do and also if it's even necessary to select 2 analog pins in the 'task resources' section of the SCS.

-Josh

  • Hi Josh,

    We have some guidance regarding analog pins in the "Project from Scratch" Sensor Controller Simplelink Academy lab. Did you take a look already?

    https://dev.ti.com/tirex/explore/node?node=ALHseLMe2AU6CVXj5vUO1w__pTTHBmu__LATEST

    Cheers,

    Marie H.

  • Hi - I think in that lab the choice of which adc input pin to use is set in the sensor controller studio (in the I/O mapping), right? My question is instead about how to choose the adc input pins at run time, in the main application c-code.

    Doing some more experimenting, it appears that:

    • The selection of ADC input pins in the I/O mapping section of the sensor controller studio is encoded in the compiled code. That is, it appears in pAuxRamImage in scif.c.
    • The selection of ADC input pins in either the I/O mapping section, or via calls to scifInitIo does not appear to have any effect on the ability to read ADC input in the sensor controller execution code.  Just having the appropriate adcSelectGpioInput() in the execution code seems to be adequate.  Is that expected behavior?

    Thanks,

    Josh

  • Hi Josh

    I have checked with our SCS expert and he confirmed that what you are doing is OK. It should not be necessary to select the 2 analog pins in the the task resources.

    BR

    Siri

  • Thanks for checking. If I uncheck "analog pins" in task resources, it seems like the compiled code is rather different, so maybe that's necessary, but it looks like which pins are selected in I/O mapping does not matter (if you call scifInitIo yourself).  I didn't test what happens if the number of ADC pins specified in task resources does not match the number of calls to scifInitIo.

    In any case, I'm good, thanks for the help.