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.

CC26xx - Sensor Controller start/stop

Other Parts Discussed in Thread: CC2650

Good morning everyone,

I'm currently trying to use at best the Sensor controller on the CC2650, with smartRF06 and Code Composer. I have integrated the Sensor Controller Interface (SCIF) with the Simple Peripheral project, and I'm able to measure the ADC level on the Light sensor. 

What I'm trying to do is simple : Init the sensor controller, begin the measurements, wait for result, disable the sensor controller. 

Init of sensor : 

void Light_Sensor_init(void)
{
   // Initialize the Sensor Controller
   scifOsalInit();
   scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
   scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
   scifInit(&scifDriverSetup);
}

Starting the sensor ; As the application may ensure that the start ticks are not in the past, i read the rtc and add some time.

SCIF_RESULT_T Light_Sensor_start_once(uint32_t tck)
{
   SCIF_RESULT_T sys ;
   uint32_t RTC_start = 0 ;

   RTC_start = AONRTCCurrentCompareValueGet();
   RTC_start |= 0x00010000;
   scifStartRtcTicks(RTC_start, tck);

   scifTaskData.analogLightSensor.cfg.hysteresis        = 16;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[0] = 0;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[1] = 400;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[2] = 600;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[3] = 800;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[4] = 1000;
   scifTaskData.analogLightSensor.cfg.pBinThresholds[5] = 4095;

   sys = scifStartTasksNbl(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID));

   return sys;
}

Wait for results : 

light = Light_Sensor_start_once(TCK_SHORT);
if(light == SCIF_SUCCESS)
{
   if(Semaphore_pend(Semaphore_handle(&semScTaskAlert),BIOS_WAIT_FOREVER))
   {
      scifClearAlertIntSource();
      uint16_t bin = scifTaskData.analogLightSensor.output.bin;
      Light_Sensor_adc_value = (uint8_t) (bin&0xFF) ;
      
      SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &Light_Sensor_adc_value);
      scifAckAlertEvents();
   }
}
Light_Sensor_stop();

And finally the function that should top the sensor controller :

void Light_Sensor_stop(void)
{
   scifStopRtcTicks();
   scifStopTasksNbl(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID));   
   scifResetTaskStructs(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID),BV(SCIF_ANALOG_LIGHT_SENSOR_STRUCT));
}

The system start and do not see an alert (event with an hysteresis of 0), next time i try to start the sensor controller it crash completely.

Thanks in advance if you have an idea how to stop and start the sensor controller in the right way

Have a nice day

EDIT :

The solution have been found and is posted .. the init function has to be called during global initialisation... then starting and stopping the sensor controller is quite easy.

  • Hi Pittet,

    Since you are not providing the alert callback I assume this contains only a simple Semaphore_post(), is that correct?

    A few hints to help you on the way:

    • scifStartRtcTicks does not take seconds as an argument but 16 bits seconds and 16 bits subseconds. Also, reading out seconds will latch it until the subseconds has been read.
    • You seem to miss scifStopTasksNbl and scifWaitOnNbl
    • The scifUninit is not necessary unless you are going to copy over a new image to the Sensor Controller

    Best regards,

    Svend

  • Other than the addition of the following to the application files and including them, how would one integrate the main capacitive touch data logger for use in the M3 application space:

    scif_framework.c

    scif_framework.h

    scif_osal_none.c

    scif_osal_none.h

    scif.c

    scif.h

    I am working on an application that detects device connection and begins notifying/advertising. With this implementation I am attempting to start the sensor controller, make a sensing event, stop the sensor controller and set a connection bit for capacitive sensing. I do not know what to implement the main of the sensor controller example into the main or application space of the project. Below is the sensor controller main output file that I am unsure of how to implement:

    void cap_main(void) {

        int n, i;
    
        // Enable power domains
        PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_SERIAL);
        while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_SERIAL) != PRCM_DOMAIN_POWER_ON);
    
        // Enable peripheral clocks
        PRCMPeripheralRunEnable(PRCM_PERIPH_UART0);
        PRCMPeripheralRunEnable(PRCM_PERIPH_GPIO);
        PRCMLoadSet();
        while (!PRCMLoadGet());
    
        // Map UART0 to DIO pins
        IOCPinTypeUart(UART0_BASE, IOID_UART_RXD, IOID_UART_TXD, IOID_UART_CTS, IOID_UART_RTS);
    
        // Configure and enable the UART (115200, 8-N-1)
        UARTConfigSetExpClk(UART0_BASE, SysCtrlPeripheralClockGet(PRCM_PERIPH_UART0, SYSCTRL_SYSBUS_ON), 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
        UARTEnable(UART0_BASE);
    
        // In this example, we keep the AUX domain access permanently enabled
        scifOsalEnableAuxDomainAccess();
    
        // Initialize and start the Sensor Controller
        scifOsalRegisterCtrlReadyCallback(ctrlReadyCallback);
        scifOsalRegisterTaskAlertCallback(taskAlertCallback);
        scifInit(&scifDriverSetup);
        scifStartRtcTicksNow(0x00010000 / 32);
        IntMasterEnable();
        AONRTCEnable();
    
        // Start the Capacitive Touch Data Logger task
        scifStartTasksNbl(BV(SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_TASK_ID));
    
        // Main loop
        while (1) {
            if (tdcValueBufferHead != tdcValueBufferTail) {
                uint16_t* pBuffer = ppTdcValueBuffer[tdcValueBufferTail];
                int pos = 0;
                for (n = 0; n < PIN_COUNT; n++) {
                    uint32_t value = pBuffer[n];
                    for (i = 0; i < 4; i++) {
                        pLineText[pos++] = nibble2char(value >> 12);
                        value <<= 4;
                    }
                    pLineText[pos++] = ' ';
                }
                pLineText[pos++] = '\r';
                pLineText[pos++] = '\n';
                pLineText[pos++] = '\0';
                uartTxString(pLineText);
                tdcValueBufferTail = (tdcValueBufferTail + 1) & 0x07;
            }
        }