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.

CC2640: Facing issue with multiple-buffered output data exchange in sensor controller studio

Part Number: CC2640


Hi,

I would like to use multiple-buffered output data exchange for my project. 

My project needs to handle data from a sensor every 5ms. I am waking up CPU by ALERT signal from SCS. 

I want to use multiple-buffered output data exchange by using  fwSwitchOutputBuffer(). I have set my buffer count as 2 so that if previous data is being handled by CPU, one buffer will be available to Sensor controller to fill the next data. 

My Task code (event handler executes every 5ms in interrupt) looks like below. 

read data from sensor;

fwSwitchOutputBuffer(); 

Application code is below 

 scifClearAlertIntSource();

opBufCnt = scifGetTaskIoStructAvailCount(SCIF_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT);
 while (opBufCnt)
 {
   opStr = (SCIF_DATA_LOGGER_OUTPUT_T *) scifGetTaskStruct(SCIF_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT);

     ACCESS DATA(); //  from opStr output buffer pointer. 

   scifHandoffTaskStruct(SCIF_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT);

  opBufCnt--;

}

scifAckAlertEvents();

I am expecting when fwSwitchOutputBuffer() is called, the currently filled buffer will be handed over to application, and the other buffer will be ready to accept new data in sensor controller task. 

My problem is below. 

1. in First iteration, for example, I filled buffer - 1 in SCtask, with value  1 and did fwSwitchOutputBuffer()

2. Main application receives value - 1 and handover buffer back. 

3. in second iteration SCTask supposed to fill buffer-2 (which was switched in step 1) with value 2. and did fwSwitchOutputBuffer().

4. Now in Main Application still I am receiving value 1 from buffer. 

I expect in step-4 I should receive value 2. 

Am I doing something wrong? 

Can someone please explain where it is going wrong??

Regards

Lakshmikanth.