• Resolved

LAUNCHXL-CC1310: Need a little help on Sensor Controller code integration

Intellectual 520 points

Replies: 28

Views: 208

Part Number: LAUNCHXL-CC1310

Setup:

Win 10 PC, Code Composer Studio Version: 10.1.1.00004, Sensor Controller Studio 2.7.0.155, Node and Concentrator project, using CC1310 as node and CC1352 as concentrator.

Success:

I had good success running TI generated code on 3 CC1310 nodes and 1 concentrator, with one ADC channel being sampled both from CCS, and from SCS. I was even to add 2 more ADC channels and successfully test (Task Test) the added ADC sampling code. 

Failure:

Now I have problems trying to compile the code generated from SCS in CCS once I added 2 more ADC channels. 

I'm just digging into the Sensor Controller Studio for the first time, and I'm stuck and I need some help figuring out why my SCS projects runs fine (I can see ADC values changing correctly) in SCS but when the same code is generated for Code Composer Studio, I get errors in the SceAdc.c file. I don't see anything in the scif_how_to_use.html about the SceAdc.c nor is there anythng in the node readme.md file about the SceAdc file, so I'm not sure where to start.

I'm not a C programmer by trade, but I have done a number of projects involving both hardware and software (a lot of assembly) design, but this is just a little beyond my reach.

Thanks,

Tim

Thanks,

Tim

  • Thanks,

    Tim

  • Guru 51785 points

    Hi Tim,

    First of all, did you take a look at the SimpleLink Academy lab on this topic?

     

    Then, in general for C code where you get the "undefined" error, please check what file file you have defined these objects in and make sure it's imported where they are used.

    Cheers,
    Marie H.

  • Guru 55925 points

    In reply to Marie H:

    It is not possible to say why you get problems with CCS when we do not know what changes you have implemented in SCS.

    Siri

     

  • In reply to Marie H:

    Thanks for the help Marie. I did go through that example but it has been a while. I'll take another look. And I will take a look at the C files imported, thanks again.

    Tim

    Thanks,

    Tim

  • In reply to Marie H:

    Hi Marie,

    I  gotta say I've developed a lot of products in my life (with ADC hardware), but I've never had this hard of time with an Analog to Digital converter software. It's funny because, I can get the TI supplied SCS applications working within SCS, but as soon as I import them to the Sensor project, I have all kinds of problems. It seems really hard to read the code, and the comments with code that is generated from the Sensor Controller Studio.

    So my question is, is there a way to modify the TI supplied Sensor code, or just simply add new code for a simple ADC task. The task is comprised:

    1. Init ADC, and ADC input port

    2. Trigger the ADC

    3. Read from the ADC FIFO

    I don't really want to use the SCS code unless that is the only way to get this simple result. If you have example code I can use, that would be terrific.

    Thank you very much,

    Tim

    Thanks,

    Tim

  • In reply to Offgrid:

    And by the way, I did do a couple of the simplelink academy for SCS, the cap switch and a couple of the ADC tasks, all worked great.  But now I'm looking at adcsinglechannel using RTOS and it looks like what I might need. Now to understand how to integrate it with my Sensor/Concentrator project.

    So it looks like I need the ADC to do two things. 

    1. Already it samples a channel, compare output value to bins (is default for 5 bins - 4096/5 or ???) , so I need it to not just sample one channel, I need two. I do have the Sensor controller code working, it's just getting my application Sensor software to read/report the ADC values.

    2. From the application, I'd like to make analog samples of some ADC channels. Right now I'm not getting much success here either.

    Thanks again!

    Tim

    Thanks,

    Tim

  • In reply to Offgrid:

    OK, update.

    I'm getting something close to working for 2 channels in the SCS. This is the ADC  project that comes from TI in the Sensor project.

    Here is the Execution Code, Init and Termination code are unchanged. My problem is that both adcValue and adcNew read the same adcNew value.

    // Enable the ADC
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    //adcEnableSync(ADC_REF_FIXED, FW_DELAY_RANGE_20_US, ADC_TRIGGER_MANUAL);
    
    
    // Sample the ADC
    S16 adcValue;
    adcGenManualTrigger();
    adcReadFifo(adcValue);
    output.adcValue = adcValue;
    
    //debug
    S16 adcValue2;
    // Select ADC input -- make new input channel = DIO30
    adcSelectGpioInput(0);
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    adcGenManualTrigger();
    adcReadFifo(adcValue2);
    output.adcNew = adcValue2;
    //debug
    
    // Disable the ADC
    adcDisable();
    
    // Alert the driver if outside of change mask
    U16 adcMaskedBits = adcValue & cfg.changeMask;
    if (adcMaskedBits != state.oldAdcMaskedBits) {
        fwGenAlertInterrupt();
        state.samplesSinceLastReport = 0;
    } else {
        state.samplesSinceLastReport = state.samplesSinceLastReport + 1;
    }
    
    //Alert driver if minimum report interval has expired
    if(cfg.minReportInterval != 0) {
        if(state.samplesSinceLastReport >= cfg.minReportInterval) {
            fwGenAlertInterrupt();
            state.samplesSinceLastReport = 0;
        }
    }
    
    // Save old masked ADC value
    state.oldAdcMaskedBits = adcValue & cfg.changeMask;

    And then here is the Task Testing Graph...please note that adcValue input is tied to GND.

    The code works perfectly for one channel when I remove all the code between the "//debug" comments:

    //debug
    S16 adcValue2;
    // Select ADC input -- make new input channel = DIO30
    adcSelectGpioInput(0);
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    adcGenManualTrigger();
    adcReadFifo(adcValue2);
    output.adcNew = adcValue2;
    //debug

    Thanks,

    Tim

  • In reply to Offgrid:

    The Test graph did not come through...so here it is

    Thanks,

    Tim

  • In reply to Offgrid:

    OK fixed the SCS output

    // Enable the ADC
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    //adcEnableSync(ADC_REF_FIXED, FW_DELAY_RANGE_20_US, ADC_TRIGGER_MANUAL);
    
    // Select ADC input (A3 / DIO26)
    adcSelectGpioInput(AUXIO_A_AD_INPUT);
    
    // Sample the ADC
    S16 adcValue;
    adcGenManualTrigger();
    adcReadFifo(adcValue);
    output.adcValue = adcValue;
    
    Now on to gettting this working in my Sensor application!
    t //debug // Change ADC input -- make new input channel = DIO30 adcSelectGpioInput(0); adcGenManualTrigger(); adcReadFifo(output.adcNew); //debug // Disable the ADC adcDisable(); // Alert the driver if outside of change mask U16 adcMaskedBits = adcValue & cfg.changeMask; if (adcMaskedBits != state.oldAdcMaskedBits) { fwGenAlertInterrupt(); state.samplesSinceLastReport = 0; } else { state.samplesSinceLastReport = state.samplesSinceLastReport + 1; } //Alert driver if minimum report interval has expired if(cfg.minReportInterval != 0) { if(state.samplesSinceLastReport >= cfg.minReportInterval) { fwGenAlertInterrupt(); state.samplesSinceLastReport = 0; } } // Save old masked ADC value state.oldAdcMaskedBits = adcValue & cfg.changeMask; // Schedule the next execution in seconds fwScheduleTask(2);

    . Now I have two channels sampling and here is the code.

    Thanks,

    Tim

  • In reply to Offgrid:

    OK, the problem with the Sensor Controller Studio code was that I needed to change the analog channel being sampled inside the Execution Code, not the Init Code. So that is fixed, and the SCS now has 2 channels sampling. Here's the SCS Execution code, note there really is no need for Init or Term code.

    // Enable the ADC
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    
    // Select ADC input (A3 / DIO26)
    adcSelectGpioInput(AUXIO_A_AD_INPUT);
    
    // Sample the ADC
    S16 adcValue;
    adcGenManualTrigger();
    adcReadFifo(adcValue);
    output.adcValue = adcValue;
    
    // Change ADC input -- make new input channel = DIO30
    adcSelectGpioInput(0);
    adcGenManualTrigger();
    adcReadFifo(output.adcNew);
    
    // Disable the ADC
    adcDisable();
    
    // Alert the driver if outside of change mask
    U16 adcMaskedBits = adcValue & cfg.changeMask;
    if (adcMaskedBits != state.oldAdcMaskedBits) {
        fwGenAlertInterrupt();
        state.samplesSinceLastReport = 0;
    } else {
        state.samplesSinceLastReport = state.samplesSinceLastReport + 1;
    }
    
    //Alert driver if minimum report interval has expired
    if(cfg.minReportInterval != 0) {
        if(state.samplesSinceLastReport >= cfg.minReportInterval) {
            fwGenAlertInterrupt();
            state.samplesSinceLastReport = 0;
        }
    }
    
    // Save old masked ADC value
    state.oldAdcMaskedBits = adcValue & cfg.changeMask;

    Now the code running on CCS looks like the TI-supplied Sensor code except this addition for second channel:

    static void adcCallback(uint16_t adcValue, uint16_t adcNew);
    
    static void adcCallback(uint16_t adcValue, uint16_t adcNew)
    {
        /* Save latest value */
        latestAdcValue = adcValue;
        latestAdcValueFromVcellHI = adcNew;
    
        /* Post event */
        Event_post(nodeEventHandle, NODE_EVENT_NEW_ADC_VALUE);
    }
    
    *****AND THEN in reading the SCE output.....
            /* Get the SCE "output" structure */
            SCIF_ADC_SAMPLE_OUTPUT_T* pOutput = scifGetTaskStruct(SCIF_ADC_SAMPLE_TASK_ID, SCIF_STRUCT_OUTPUT);
    
            /* Send new ADC value to application via callback */
            if (adcCallback)
            {
                adcCallback(pOutput->adcValue, pOutput->adcNew);
            }

    I hope this helps someone else, since I spent way too much time trying to figure out what the TI-supplied software was trying to do (I'm not gonna say how much time!).

    Tim

    Thanks,

    Tim