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: Timer to calculate the time

Part Number: CC2640

Hello,

I want to use a timer in cc2640 for calculating the some time. Which timer is available in cc2640? is there any example for that? 

I tried the following but it does not work

Clock_Struct periodic;
Util_constructClock(&periodic, clock_callback,
3000, 0, true, 0);
Util_startClock(&periodic);
bool status=Util_isActive(&periodic);

waiting for your kind reply.

Regards

  • Util_constructClock(&periodicClock, clockHandler,0, Period, false, 0);
    Util_startClock(&periodicClock);
  • Hello,

    I start the timer after sending the notification to the client. I want to send notification again when timer gets expired. But I observed when the timer gets expired and call_back is called, it get hang in call_back function and does not send any notification to client. It does not proceed further.
  • Hi mabbas,

    You cannot send the notification in Call_back function. You should use Semaphore to set the event/queue on Task. Because you have to wait for complete the important other task. It's fast. You will see like everything happens at the same time. This is my example for use timer to set event and wake up semaphore

    //!Create one-shot clocks 
    Util_constructClock( &periodicClock, clockHandler,_PERIOD, 0, false, _PERIODIC_EVT );
    Util_startClock(&periodicClock); 
    
    static void FxnTask( UArg a0, UArg a1 )
    {
       ....
    
       if ( events & _PERIODIC_EVT )
       {
          events &= ~_PERIODIC_EVT;
          Util_startClock( &periodicClock );
          //!Perform periodic application task
          performPeriodicTask();
       }
       ....
    }
    
    static void clockHandler(UArg arg)
    {
      // Store the event.
      events |= arg;
    
      // Wake up the application.
      Semaphore_post(sem);
    }

  • Hi Vy Luu,

    I am using queue in the call back and then process the queue event to send the notifications.
  • Hi mabbas,

    Do you fix your issue? If it still does not work, you need to post more details
  • Hi Vy Luu,

    I have resolved the issue. Can you tell me where in SimpleBLEPeripheral_taskFxn i can generate an event? Then i want to stop the advertising.