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.

Sensor controller studio coding

Other Parts Discussed in Thread: CC2640, SYSBIOS

1.I am trying to use SCS to test the ADC function of CC2640, I added a Battery into the output data structure(shown in figure 1), why there is a error in the second page?

2. I tried to use utilIncrAndWrap function like in the "ADC data logger" example, the SCS report an error. can I directly use it or I have to configure some settings?

Thanks!

  • Hello Di Wang,
    This might be a bug. Lets find out.
    Can you show me the details of your RAM variable output.BATTERY?
    Try using lower case letters in stead (battery).
  • Hi Eirik,

    Thanks for your quick reply! the picture below is the details of this variable.

    Di

  • Lower case works! thanks!
  • Great,
    1) It was indeed a bug and will be fixed in a future version.
    2) Go to task panel and enable Utilities -> Math and Logic.
  • Hi Eirik,

    I am trying to integrate these ADC measurement code into CCS simpleBLEPeripheral project, and achieve measurement every second and send them through BLE, but the voltage reading is always 0 in CCS during debug(~1 voltage is applied on the battery pin), but the reading in SCS works fine. what could be the reason? the figures and the code in scif_task.c which I created is listed as below, thanks!

    #include "scif.h"
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/BIOS.h>
    #include <Board.h>
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    #include <inc/hw_gpio.h>
    #include <driverlib/prcm.h>
    #include <driverlib/gpio.h>
    #include <inc/hw_ioc.h>
    #include <driverlib/aon_rtc.h>

    #define BV(n) (1 << (n))
    #define IOC_O_IOCFG(n) (IOC_O_IOCFG0 + (sizeof(uint32_t) * n))

    #define DISABLE_LOW_POWER 0

    #define Board_LED IOID_4
    #define Board_Battery IOID_12
    #define Board_VOC IOID_13
    #define Board_NO2 IOID_14

    //static uint16_t batteryValue=0;
    //static uint16_t no2Value=0;
    //static uint16_t vocValue=0;

    // Task data
    Task_Struct myTask;
    Char myTaskStack[512];

    /*********************************************************************
    * LOCAL VARIABLES
    */
    // Parameters
    uint16_t batteryValue;
    uint16_t no2Value;
    uint16_t vocValue;

    // 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 PinsCfg[] =
    {
    Board_LED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_Battery | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS,
    Board_VOC | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS, /* */
    Board_NO2 | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS,
    PIN_TERMINATE
    };

    PIN_State Pins;
    PIN_Handle hPins;


    void taskFxn(UArg a0, UArg a1) {


    hPins = PIN_open(&Pins, PinsCfg);
    // PIN_registerIntCb(hKeyPins, Board_keyCallback);

    // PIN_setConfig(hKeyPins, PIN_BM_IRQ, IOID_KEY_LEFT | PIN_IRQ_NEGEDGE);
    // PIN_setConfig(hKeyPins, PIN_BM_IRQ, IOID_KEY_RIGHT | PIN_IRQ_NEGEDGE);


    // In this example, we keep the AUX domain access permanently enabled
    //scifOsalEnableAuxDomainAccess();

    // Initialize and start the Sensor Controller
    scifOsalInit();
    scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
    scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
    scifInit(&scifDriverSetup);
    // Set the Sensor Controller task tick interval to 1 second
    scifStartRtcTicksNow(0x00010000);
    //scifStartTasksNbl(BV(SCIF_LED_BLINKER_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();

    batteryValue = scifTaskData.adcI2c.output.battery;
    no2Value = scifTaskData.adcI2c.output.no2;
    vocValue = scifTaskData.adcI2c.output.voc;

    // Acknowledge the alert event
    scifAckAlertEvents();

    }

    } // taskFxn


    /*********************************************************************
    * @fn scif_createTask
    *
    * @brief Task creation function for the sensor controller application.
    *
    * @param None.
    *
    * @return None.
    */
    void scif_createTask(void)
    {
    Task_Params taskParams;

    // 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);
    }