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.

CC2642R: ADC Sensor Controller Studio x SCIF Framework

Part Number: CC2642R
Other Parts Discussed in Thread: SIMPLELINK-CC13XX-CC26XX-SDK

Hi,

I'm new using the sensor controller and sensor controller studio.

I need a fast response when the ADC exceeds the high threshold. I think the example ADC Windows Monitor does that. 

I just changed the IO and the adcWindowHigh limit of this example and when I executing this example using the Task Testing, it works fine. I can see the expected behavior and correct values.


But when I import the project into the code composer studio, I can't see the same behavior, the interrupt never occurs.

I try to include a volatile variable to run continuously the application but this variable never changes.

This is my changed code:

   

...
// Task data
Task_Struct myTask;
Char myTaskStack[1024];


// Semaphore used to wait for Sensor Controller task ALERT event
static Semaphore_Struct semScTaskAlert;
volatile uint8_t state;




void scCtrlReadyCallback(void) {

} // scCtrlReadyCallback




void scTaskAlertCallback(void) {

    // Wake up the OS task
    Semaphore_post(Semaphore_handle(&semScTaskAlert));

} // scTaskAlertCallback




PIN_Config pLedPinTable[] = {
    Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};
PIN_State ledPinState;


void taskFxn(UArg a0, UArg a1) {
    PIN_Handle hLedPins;

    // Enable LED pins
    hLedPins = PIN_open(&ledPinState, pLedPinTable);

    // Initialize the Sensor Controller
    scifOsalInit();
    scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
    scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
    scifInit(&scifDriverSetup);
    scifStartRtcTicksNow(0x00010000 / 8);

    // Configure and start the Sensor Controller's ADC window monitor task (not to be confused with OS tasks)
    scifTaskData.adcWindowMonitor.cfg.adcWindowHigh = 3300;
    scifTaskData.adcWindowMonitor.cfg.adcWindowLow  = 0;
    scifStartTasksNbl(BV(SCIF_ADC_WINDOW_MONITOR_TASK_ID));

    // Main loop
    while (1) {

        // Wait for an ALERT callback
        Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);

        // Clear the ALERT interrupt source
        scifClearAlertIntSource();

        // Indicate on LEDs whether the current ADC value is high and/or low
        if (scifTaskData.adcWindowMonitor.output.bvWindowState & SCIF_ADC_WINDOW_MONITOR_BV_ADC_WINDOW_LOW) {
            PIN_setOutputValue(hLedPins, Board_GLED, 1);
            state = 1;
        } else {
            PIN_setOutputValue(hLedPins, Board_GLED, 0);
            state = 2;
        }
        if (scifTaskData.adcWindowMonitor.output.bvWindowState & SCIF_ADC_WINDOW_MONITOR_BV_ADC_WINDOW_HIGH) {
            PIN_setOutputValue(hLedPins, Board_RLED, 1);
            state = 3;
        } else {
            PIN_setOutputValue(hLedPins, Board_RLED, 0);
            state = 4;
        }

        // Acknowledge the alert event
        scifAckAlertEvents();
    }

} // taskFxn
...

And this is the debugging information's:

And when I read the same DIO using just the HAL driver, I can read practically the same values as when I use the Task Testing.

This my adc configuration:

I use:

Sensor Controller Studio: Version 2.6.0.132.

Code Composer Studio: Version: 11.1.0.00011.

Both with SimpleLink CC13x2 26x2 SDK 3.40.00.02.

Thanks in advance,

Cristiane Bellenzier Piaia

 

  • Hi Cristiane,

    Here is a link to the Sensor Controller Fundamentals SLA.  I am not observing similar behavior using IOID_30, however I am evaluating with the SIMPLELINK-CC13XX-CC26XX-SDK v6.10 and have not changed the adcWindowHigh/adcWindowLow values from their defaults.  I recommend that you try the same and verify the default example project exactly as it is imported into CCS before making your application changes.  It will be difficult to trigger the "window" functionality by using values at their extremes.  You should not need to configure the ADC inside CCS as this is already accomplished by Sensor Controller Studio code generation.

    Regards,
    Ryan

  • Good morning Ryan,

    thanks for the quick reply. 

    I tried what you said. In my new test, I just changed the DIO to use 30. 

    The result in Sensor Controller is the same, works fine:

    But when I try in Code Composer, the interrupt doesn't happen. :(

    The code is the default, in this test I did not changed anything:

      

    //*****************************************************************************
    //  SENSOR CONTROLLER STUDIO EXAMPLE: ADC WINDOW MONITOR FOR LAUNCHPAD
    //  Operating system: TI-RTOS
    //
    //  The Sensor Controller is used to sample a single ADC channel and monitor
    //  the value. The Sensor Controller updates a bit-vector that indicates
    //  whether the ADC value is:
    //  - Below a configurable low threshold
    //  - Above a configurable high threshold
    //
    //  The Sensor Controller notifies the application when the bit-vector changes
    //  (triggering scTaskAlertCallback()), and the application sets the LEDs as
    //  follows:
    //  - Green LED is set whenever the ADC value is below the low threshold
    //  - Red LED is set whenever the ADC value is above the high threshold
    //
    //
    //  Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    //
    //  Redistribution and use in source and binary forms, with or without
    //  modification, are permitted provided that the following conditions
    //  are met:
    //
    //    Redistributions of source code must retain the above copyright
    //    notice, this list of conditions and the following disclaimer.
    //
    //    Redistributions in binary form must reproduce the above copyright
    //    notice, this list of conditions and the following disclaimer in the
    //    documentation and/or other materials provided with the distribution.
    //
    //    Neither the name of Texas Instruments Incorporated nor the names of
    //    its contributors may be used to endorse or promote products derived
    //    from this software without specific prior written permission.
    //
    //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //****************************************************************************/
    #include "ex_include_tirtos.h"
    #include "scif.h"
    
    
    #define BV(n)               (1 << (n))
    
    
    // Display error message if the SCIF driver has been generated with incorrect operating system setting
    #if !(defined(SCIF_OSAL_TIRTOS_H) || defined(SCIF_OSAL_TIDPL_H))
        #error "SCIF driver has incorrect operating system configuration for this example. Please change to 'TI-RTOS' or 'TI Driver Porting Layer' in the Sensor Controller Studio project panel and re-generate the driver."
    #endif
    
    // Display error message if the SCIF driver has been generated with incorrect target chip package
    #ifndef SCIF_TARGET_CHIP_PACKAGE_QFN48_7X7_RGZ
        #error "SCIF driver has incorrect target chip package configuration for this example. Please change to 'QFN48 7x7 RGZ' in the Sensor Controller Studio project panel and re-generate the driver."
    #endif
    
    
    // Task data
    Task_Struct myTask;
    Char myTaskStack[1024];
    
    
    // Semaphore used to wait for Sensor Controller task ALERT event
    static Semaphore_Struct semScTaskAlert;
    
    
    
    
    void scCtrlReadyCallback(void) {
    
    } // scCtrlReadyCallback
    
    
    
    
    void scTaskAlertCallback(void) {
    
        // Wake up the OS task
        Semaphore_post(Semaphore_handle(&semScTaskAlert));
    
    } // scTaskAlertCallback
    
    
    
    
    PIN_Config pLedPinTable[] = {
        Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    PIN_State ledPinState;
    
    
    void taskFxn(UArg a0, UArg a1) {
        PIN_Handle hLedPins;
    
        // Enable LED pins
        hLedPins = PIN_open(&ledPinState, pLedPinTable);
    
        // Initialize the Sensor Controller
        scifOsalInit();
        scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
        scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
        scifInit(&scifDriverSetup);
        scifStartRtcTicksNow(0x00010000 / 8);
    
        // Configure and start the Sensor Controller's ADC window monitor task (not to be confused with OS tasks)
        scifTaskData.adcWindowMonitor.cfg.adcWindowHigh = 800;
        scifTaskData.adcWindowMonitor.cfg.adcWindowLow  = 400;
        scifStartTasksNbl(BV(SCIF_ADC_WINDOW_MONITOR_TASK_ID));
    
        // Main loop
        while (1) {
    
            // Wait for an ALERT callback
            Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);
    
            // Clear the ALERT interrupt source
            scifClearAlertIntSource();
    
            // Indicate on LEDs whether the current ADC value is high and/or low
            if (scifTaskData.adcWindowMonitor.output.bvWindowState & SCIF_ADC_WINDOW_MONITOR_BV_ADC_WINDOW_LOW) {
                PIN_setOutputValue(hLedPins, Board_GLED, 1);
            } else {
                PIN_setOutputValue(hLedPins, Board_GLED, 0);
            }
            if (scifTaskData.adcWindowMonitor.output.bvWindowState & SCIF_ADC_WINDOW_MONITOR_BV_ADC_WINDOW_HIGH) {
                PIN_setOutputValue(hLedPins, Board_RLED, 1);
            } else {
                PIN_setOutputValue(hLedPins, Board_RLED, 0);
            }
    
            // Acknowledge the alert event
            scifAckAlertEvents();
        }
    
    } // taskFxn
    
    
    
    
    int main(void) {
        Task_Params taskParams;
    
        // Initialize the board
        Board_initGeneral();
    #ifdef Board_shutDownExtFlash
        Board_shutDownExtFlash();
    #endif
    
        // Configure the OS task
        Task_Params_init(&taskParams);
        taskParams.stack = myTaskStack;
        taskParams.stackSize = sizeof(myTaskStack);
        taskParams.priority = 3;
        Task_construct(&myTask, taskFxn, &taskParams, NULL);
    
        // Create the semaphore used to wait for Sensor Controller ALERT events
        Semaphore_Params semParams;
        Semaphore_Params_init(&semParams);
        semParams.mode = Semaphore_Mode_BINARY;
        Semaphore_construct(&semScTaskAlert, 0, &semParams);
    
        // Start TI-RTOS
        BIOS_start();
        return 0;
    
    } // main
    

    Now I will try to used the same sdk you used, but I need it's work with the version 3.40.00.02. because my project use this version.

    Thanks in advanced,

    Cristiane Bellenzier Piaia

  • Is the IOID_30 pin already high when you run the firmware through the CCS debugger, and does the low threshold interrupt as expected?  Validating with the newer SDK would determine whether the issue resides with the old SDK or your project setup/expectations.  Would it be easier for you to use the SCS GPIO Event trigger or PIN/GPIO TI Drivers to create an interrupt callback, or are ADC readings necessary for your application?

    Regards,
    Ryan

  • Hi Ryan,

    Sorry for the delay to update you about the test with the 6.10 SKD.

    I tried the same example with the 6.10 SDK and works, with Sensor Controller and with Code Composer.

    I receive the interrupt with the expected behavior. 

  • With the 3.40 version I do not receive the interrupt as expected. And as I could see with the 6.10 version.

    I can validate other solution, but I need a very quick response because I need to solve a power failure situation, the response time is crucial.

    Thanks again for the response,

    Cristiane Bellenzier Piaia

  • Thanks for providing more details from your tests.  Do you require any further responses on this topic or can the E2E thread be closed?  The only related issue I could find so far involves a workaround which adds a delay between adcEnableSync and adcGenManualTrigger: https://e2e.ti.com/f/1/t/878137 

    Regards,
    Ryan

  • Hi Ryan,

    the workaround do not work for me, I still don't receive the interrupt.

    I will try a solution using comparator directly now.

    Thanks again,

    Cristiane Bellenzier Piaia

  • Why is is not feasible to migrate the solution to the latest SDK?  This will include more than two years worth of bug BLE5 fixes, updated features, and upgraded tools.  There are BLE5-Stack Migration Guides to assist this process as well.

    Regards,
    Ryan