cancel
Showing results for 
Search instead for 
Did you mean: 

Problem With Virtual Timer

nooshin_1382
Associate II
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 discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions
disirio2
Senior
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

View solution in original post

1 REPLY 1
disirio2
Senior
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