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.

breakpoint not reaching semaphore post

Other Parts Discussed in Thread: CC2640, SYSBIOS

Hi,

I'm working on a CC2640 4x4 custom application, BLE stack 2.2, CCS 2.2, TI RTOS 2.18, sensor controller 1.3, XDS 200 debugger.

I have two tasks Task A (simple_peripheral) being a higher priority than Task B (uart emulator in sensor controller). Task B has two semaphores it waits on, one from the sensor controller and another from Task A. I want Task B to stop when Task A posts its semaphore. A breakpoint placed in Semaphore_post in Task A never gets executed. Why might this be? In this scenario, the semaphore from the sensor controller in Task B will never happen because there is no uart activity.

Thank you,

Priya

  • Hi Priya,

    Can you post some code of Task A and Task B, also the initialization code would be necessary to see what is going on?
    What happens when you pause the debugger?
    Does it point to a valid instruction in your code?

    What is in the Task Detailed view in the ROV when you pause?

    Regards,
    Michel
  • Michel-- thank you for your reply. I had to call the function to stop the emulator in addition to posting the semaphore. The uart emulator is closing now. I may be back for more help because the rest of the uart processing has to transfer over to using the emulator.

    Priya
  • I am opening this thread again. The semaphore post and pend from task A to task B is working but I need to have a breakpoint in place. If I run the code with no breakpoints scifUartStopEmulator(); never gets executed. Should I be adding anything to the .cfg file?

    Thanks,
    Priya


    Here is an outline of what's happening:

    void uartEmulator_taskFxn(UArg a0, UArg a1) {
    sensorController_init();
    start_uartEmulator();

    } // taskFxn

    static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
    {
    if (pEvt->event_flag & SBP_ADV_CB_EVT)
    {uint32 ticks = Clock_getTicks();
    if (!uartClosed) {
    if (ticks > 5000 && !talkMode) {
    Semaphore_post(Semaphore_handle(&semUartTaskAlert));
    stopUartEmulator();
    }
    }

    void stopUartEmulator(void)
    {
    while(1){
    Semaphore_pend(Semaphore_handle(&semUartTaskAlert), BIOS_WAIT_FOREVER);
    CPUdelay((100 * 1000 * 48) / 3);
    scifUartStopEmulator();
    uartClosed = 1;
    scifResetTaskStructs(BV(SCIF_UART_EMULATOR_TASK_ID), 0xF);
    scifStopTasksNbl(BV(SCIF_UART_EMULATOR_TASK_ID));
    }
    }
  • Hi Priya,

    There are a few things that seem to be off but it could just be pseudo-code.

    Here are some things to check:

    • Did you declare and define the callback functions from the sensor controller? That's the only way that you can receive events from the sensor controller.
    • The logic seems to weird in your SimpleBLEPeripheral_taskFxn. There is a loop inside the stopUartEmulator function which pends on a semaphore that it posted earlier (just before entering stopUartEmulator).That means that it will pend once and then wait for the semaphore forever because the task will never post it again (it is stuck inside the while(1) loop in stopUartEmulator). Is that the intended action of your tasks?
    • There is no loop in the uartEmulator_taskFxn: does this functions only execute the init and then leave? If so, this will not cause any problems but those are wasted ressources because you would need to do a Task_delete to recover the memory (stack and other) used by that task, unless that is already done somewhere.

    Have you looked at the examples to understand how to use the sensor controller? There are some great examples in the Start page of Sensor Controller Studio. It even provides the .c source code for integration in your code (with the initialization, includes, callbacks, etc.)

    Otherwise, can you post more detailed code so we can see what could possibly be wrong? (Please Use Rich formatting at the bottom right corner and click the Insert code button to post your code. It will make it much easier to read)


    Michel

  • Michel,

    I have attached more detail in the code as I tried this morning. The waitForUARTMessage function takes care of starting and monitoring the uart emulator. I removed the while (1) loops in the start and stop functions of the uart emulator. The Semaphore_post breakpoint inside SimpleBLEPeripheral_taskFxn is not executing at all today. The uart emulator starts and the execution does not reach this breakpoint. No Hwi exceptions reported in ROV. 0272.simple_peripheral_SCS.c

    There is nothing driving the uart so no callback will come from the sensor controller. Is there a built feature inside the sensor controller that can shut itself down if there is no uart activity on start up after a few seconds?

    Thanks,

    Priya

  • Hi Priya,

    I've looked at the code and I have a hard time understanding what you are trying to accomplish.

    I have a few questions to clarify what you are requesting:

    Why do you want to stop the second task?

    You want to stop listening to the UART on the sensor controller? This would be much simpler to do using the UART driver instead of the UART emulator.

    Another reason why you don't need to stop listening: The sensor controller doesn't take much ressources since you are only waiting on the uart events which come sporadically. These events should not prevent your other task from working.

    How do you want to wait for two semaphores? That means that you cannot wait on two semaphores simultaneously (unless you use intrinsic events, but they are not supported if you are using SYSBIOS in ROM) In that case, you would have to use events (events are binary so you cannot count how many times the events occured)

    Michel

  • Thank you for your reply and the clarification about semaphores. The sensor controller needs to be shut down for the 1uA standby current in a battery operated product. The UART is used only during calibration, not in steady state operation. I believe I tried setting up a new event before I tried semaphores-- there is more to learn in RTOS. The UART state machine developer is working on a new bug fix. Hopefully the UART driver can be made to work.

    Priya