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: sensor controller studio stops GPIO event trigger suddenly

Part Number: CC2640
Other Parts Discussed in Thread: ADS1293

Hello All,

I am using SCS for accessing my SPI device. My SPI device generates interrupt every 5ms. I am configuring sensor controller studio for receive GPIO trigger. 

I am receiving a couple of ALERTS from event handler in Main CPU code. After that, SCS stops GPIO Trigger event. Even though my SPI device is asserting GPIO Line. 

I have given my code below (both SCS and CCS). 

Not sure where I am going wrong. Please guide me. 

 

Below is my event handler code: 

//Event handler code in SCS 

spiBegin(SPI_POL0_PHA0, AUXIO_SPI_CSN_ADS1293_CSB );  // CS Low

spiTx8bit(SPI_POL0_PHA0, 0xD0);  // Read command

for (U16 n = 0; n < 9; n++) {

spiRx8bit(SPI_POL0_PHA0; output.ecgData[n]);   // Read data from SPI device

}

spiEnd(SPI_POL0_PHA0, AUXIO_SPI_CSN_ADS1293_CSB);  // CS High

evhSetupGpioTrigger(0, AUXIO_I_ADS1293_DRDYB, 0, EVH_GPIO_TRIG_ON_EDGE); // Program next trigger

fwGenAlertInterrupt();  // Notify CPU. 

Below is my Main CPU ALERT handler: 

// Main loop
while (1) {

// Wait for an ALERT callback
Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);
// Clear the ALERT interrupt source
scifClearAlertIntSource();

devID = scifTaskData.dataLogger.output.deviceID;
filter = scifTaskData.dataLogger.output.filter;
for(i=0;i<9;i++)
ecgData[i] = scifTaskData.dataLogger.output.ecgData[i];

// Acknowledge the alert event
scifAckAlertEvents();

}

Regards

Lakshmikanth. 

  • Hello Lakshmi,
    The GPIO pin is sampled at 32 kHz, and must be held active for at least 2 x 32 kHz periods to be captured safely. This is explained in the Help viewer in the section for evhSetupGpioTrigger().

    Have you observed your interrupt signal to ensure it is slow enough to be captured?
  • Hi Eirik,

    As mentioned, GPIO pin asserted every 5ms (Active Low). And the event is getting generated couple of times initially and then stopped.

    Regards

    Lakshmikanth. 

  • Can you capture a logic analyzer plot for the SPI lines and the interrupt line at the same time?
  • Please find attached.

    This was captured capture  when the trigger was working initially. The signal in RED is GPIO.

    After two or three such transactions, Trigger stops working even if GPIO asserted.

    Regards

    Lakshmikanth

  • Have your tried to trigger on match instead of edge (EVH_GPIO_TRIG_ON_MATCH)?
  • Yes. But sometimes it generates, sometimes not.

    Regards
    Lakshmikanth.
  • In the cases where sensor controller does not trigger, for how long is the interrupt signal held low? Do you have a plot of the signal for this condition?
  • Hi Eirik,

    It held low for 5 ms. I am attaching the capture for high to low assertion. Please check. 

    Regards

    Lakshmikanth

  • Hello,
    Can you share your SCS project with me and also show me how you initialize the sensor controller driver from your main application (code)?
  • ADS1293_DataLogger_to_Eirik.zipHI Eirik,

    Please find SCS project attached. Below is my main application code.

    int main(void) {
    Task_Params taskParams;

    // Initialize the PIN driver
    PIN_init(BoardGpioInitTable);

    // 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

    void taskFxn(UArg a0, UArg a1) {

    uint16_t devID;
    uint16_t filter;
    uint16_t ecgData[10];
    int i=0;

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

    // ADS1293 register configuration
    TI_ADS1293_WriteRegSettings();

    // Configure and start the Sensor Controller's Analog Light Sensor task (not to be confused with OS tasks)
    scifStartTasksNbl(BV(SCIF_DATA_LOGGER_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();

    devID = scifTaskData.dataLogger.output.deviceID;
    filter = scifTaskData.dataLogger.output.filter;
    for(i=0;i<9;i++)
    ecgData[i] = scifTaskData.dataLogger.output.ecgData[i];


    // Acknowledge the alert event
    scifAckAlertEvents();
    }

    } // taskFxn

  • Hi Eirik,

    Here are few more observations.

    I have added a GPIO output in event handler to check if my Event is getting generated or not.

    I found my GPIO event is getting triggered. But for some reason, SPI interface in event handler is not working. I don't see any activity on SPI Bus. The same SPI operations are performing well in Initialization code.

    I also found time takes to wake up main CPU ( by fwGenQuickAlertInterrupt(); ) and come back from CPU is taking 35ms, hence some of GPIO events are missing.

    Please find attached screenshot. D5 signal is DIO_0 pin used for toggling. D0 is my GPIO event.

    Lakshmikanth

  • You sent me the wrong SCS project. There is no event handler setup.
  • Hi Erik,

    What do you mean by event handler setup?

    I have added below code in Event handler code, and I have enabled Digital input pins in task setup and named the pin as ADS1293_DRDYB. I also enabled the GPIO Event Trigger option in Task Event Handling section. I able to see all these in the same project which I have sent to you.

    Please let me know if anything else needed.

    Event Handler code:

    spiBegin(SPI_POL0_PHA0, AUXIO_SPI_CSN_ADS1293_CSB );
    spiTx8bit(SPI_POL0_PHA0, 0xD0);
    for (U16 n = 0; n < 9; n++) {

    spiRx8bit(SPI_POL0_PHA0; output.ecgData[n]);

    }
    spiEnd(SPI_POL0_PHA0, AUXIO_SPI_CSN_ADS1293_CSB);

    evhSetupGpioTrigger(0, AUXIO_I_ADS1293_DRDYB, 0, EVH_GPIO_TRIG_ON_EDGE);

    fwGenAlertInterrupt();
    //fwGenQuickAlertInterrupt();

    Regards
    Lakshmikanth.
  • Seems like you sent me a zipped SCS project for me to review which does not reflect the project you describe. Please send the correct one for me to review.

  • Sorry, I found it now. To many files in my download folder caused a mixup :). I am looking at it now.
  • Hello,

    At first glance the projects seems good. However try to make the changes given in the review below.

    1st round Review:

    1)

    You do not need the RTC-Based Execution Scheduling. remove this line:

    scifStartRtcTicksNow(0x00010000 / 8);

    2)

    use EVH_GPIO_TRIG_ON_MATCH

     

     

  • Hi Eirik,

    I will try your suggestions and update you soon.

    Meanwhile below are few observations. 

    I am toggling a GPIO pin in event handler to check if my Event is getting generated or not.

    1) I found my GPIO events are getting triggered always. But for some reason, SPI interface in event handler is not working. I don't see any activity on SPI Bus. The same SPI operations are performing well in Initialization code.

    2) I also found time takes to wake up main CPU ( by fwGenQuickAlertInterrupt(); ) and come back from CPU is taking 35ms, hence some of GPIO events are missing since my trigger programmed for 5ms.

    What could be the reason for SPI not working in event handler?

    Regards

    Lakshmikanth

  • Hi Eirik,

    I have tried with your suggestions. I observed below things. 

    1)  After few event triggers went on properly, I observed MOSI line is asserted high suddenly before next trigger.

    2) CS line also getting asserted after that.  

    3) Once this happens SPI bus stops working but events are getting triggered. 

    I disabled ALERT indication to CPU and tried. but still I see above scenario.  Any idea why these lines getting asserted without my knowledge? 

    I have attached protocol analyzer screen for your reference. 

    Regards

    Lakshmikanth

  • Hello lakshmikanth,

    Are you sure you are not also using these pins in your TI-RTOS application?

  • Hi Eirik,

    I have made sure these pins are not being used in my TI-RTOS.

    I enabled MAIN CPU's SPI0 (SSI) on same pins to check if it is working. It is working perfectly. When I use SPI from Sensor controller studio, I don't see any activity over the SPI Bus.

    Is there any limitation on bitbang SPI of SCS ?

    Best
    Lakshmikanth
  • Not that I know of. You can try to set the SPI bit rate to balanced (1.1MHz) and test. I do not know why the bit rate would impact the stability in your case, but it's worth a try. It does not make any sense that MOSI is asserted before chip select!

    Also it seems like the MISO signal is active high so you can try to set the MISO config on init to "low" instead of "high":