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.

RTOS/cc2650: Stop the sensor controller task

Part Number: CC2650
Other Parts Discussed in Thread: CC2650

Tool/software: TI-RTOS

Hi,

I'm developing an application using CCS and sensor controller studio.

In sensor controller side I have Initialization code that enables the sensor connected to the CC2650 using I2C and change the modules I2C address, then I have Execution code that reads some data from module over I2C, and then termination code that disable the sensor to save power. 

everything is working well and I can read the measurement from sensor correctly. Now in main CPU side I need to for example keep the execution code running for 5 seconds and the make it off (using Termination code) and then after 5 second run the Initialization code and then execution code (every 1 m seconds).

For the first initialization and then running execution code for 5 second everything is working. But once I run the termination code and wait for 5 second and then Initialization again it seems that the Execution code wont run.

Am I doing wrong for the second initialization?

Here is the task I have:

Void lidar_task(UArg arg0, UArg arg1)
{
	// Initializes linked list for s1 and s2
    init_sens_structs();
    bool lidar_active=true;
//	uint8_t connectionEstablished = establish_connection();
//
//	if(!connectionEstablished)
//	{
//		System_printf("connection not established");
//		System_flush();
//	}
//	else
//	{
//		System_printf("connection established");
//		System_flush();
//	}

    while(1){


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

		// Set the Sensor Controller task tick interval to 1 millisecond
		scifStartRtcTicksNow(65);




		// Configure to trigger interrupt at first result, and start the Sensor Controller's I2C Light
		// Sensor task (not to be confused with OS tasks)
		scifStartTasksNbl(BV(SCIF_I2C_LIGHT_SENSOR_TASK_ID));

		// Checks the status of the task
		uint16_t status = scifTaskData.i2cLightSensor.state.i2cStatus;
		if (status!=0x00)
		{
			System_printf("I2C Error!!!!\n");
			System_flush();
		}

		UInt32 t; // Stores time of detection
		UInt32 t_t; // Stores time of detection
		t_t = Clock_getTicks()/100;
		System_printf("New Loop!!!!\n");
		System_flush();
		// Main loop
		while (lidar_active) {

			// Pauses task and moves on to cyclist_al gorithm for processing
			Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
			// At this point, a HWI has occurred and data will be stored into a linked list

			// Clear the ALERT interrupt source
			scifClearAlertIntSource();

			// Converts clock ticks to milliseconds
			t = Clock_getTicks()/100;
			if ((t -t_t) > 5000){
				lidar_active=false;
				t_t = Clock_getTicks()/100;
			}
			// Adds data to sensor 1 and sensor 2 linked lists
			add_1(t, scifTaskData.i2cLightSensor.output.value[0]*10);
			add_2(t, scifTaskData.i2cLightSensor.output.value[1]*10);
			PIN_setOutputValue(ledPinHandle, Board_LED0,
									   !PIN_getOutputValue(Board_LED0));

			// Acknowledges event/HWI
			scifAckAlertEvents();
		}
		PIN_setOutputValue(ledPinHandle, Board_LED0, 0);
		scifStopTasksNbl(BV(SCIF_I2C_LIGHT_SENSOR_TASK_ID));

		while (!lidar_active){
			Task_sleep(1000000 / Clock_tickPeriod);
			t=Clock_getTicks()/100;
			System_printf("time: %i\n", t);
			 System_flush();
			if ((t -t_t) > 5000){
				lidar_active=true;
				t_t = Clock_getTicks()/100;
			}

		}

	}
}