Skip to main content
nooshin_1382
Associate III
February 9, 2015
Solved

Problem With Virtual Timer

  • February 9, 2015
  • 1 reply
  • 689 views
Posted on February 09, 2015 at 07:45

Hi

I Want to use a virtual timer in my program , i think the code is ok but when i debug it the program all is in this function : static void tmrfunc(void *p)

please see the code and say to me what wrong in my program .

#include ''components.h''

static virtual_timer_t tmr;

uint8_t Timer_Flag= 0;

/*

 * @brief   Timer callback function.

 *

 * @param[in] p         NULL

 *

 * @notapi

 */

static void tmrfunc(void *p)

{

  (void)p;

  osalSysLockFromISR();

  vtSetI(&tmr, OSAL_MS2ST(500), tmrfunc, NULL);

  osalSysUnlockFromISR();

  Timer_Flag= 1;

}

/*

 * Application entry point.

 */

int main(void)

{

  /* Initialization of all the imported components in the order specified in

     the application wizard. The function is generated automatically.*/

  componentsInit();

  /* Interrupts are enabled and the system is ready.*/

  osalIsrEnable();

     vtSet(&tmr, OSAL_MS2ST(500), tmrfunc, NULL);

  while (1)

  {

       if (Timer_Flag== 1)

       {

            palTogglePad(PORT_C, PC_LED7);

       }

}
    This topic has been closed for replies.
    Best answer by disirio2
    Posted on February 10, 2015 at 18:51

    Hi,

    You set Timer_Flag only to 1 and never to 0. Try toggling the LED directly inside the callback.

    giovanni

    1 reply

    disirio2
    disirio2Best answer
    Associate III
    February 10, 2015
    Posted on February 10, 2015 at 18:51

    Hi,

    You set Timer_Flag only to 1 and never to 0. Try toggling the LED directly inside the callback.

    giovanni