AnsweredAssumed Answered


Question asked by Riccardo Gennari on Oct 20, 2011
Latest reply on Dec 13, 2011 by Petr MacHala

I have a problem that I can not give me an explanation.
I created a timer as shown by the examples of mql.
This timer should expire once after 30 seconds but if I want a scgiacciando Stasta initialising it is deleted and a new timer expires 30 seconds after my decision.
This can riperete my decision over and over again.
I see that the gate that I _timer_id _timer_cancel interrorro actually, but when I reset the value of _timer_id grows in value.
I wonder, but doing so makes me think that it has effectively canceled the previous and then continues to allocate new memory ... more and more? MQX, or with the function _timer_cancel (timer_id) also frees the memory that had once been reserved for the timer at the time of its creation?
Here is my code:


_timer_id timer_backlightvoid InitTIMER(void){   /*    ** Create the timer component with more stack than the default   ** in order to handle printf() requirements:    */   _timer_create_component(TIMER_DEFAULT_TASK_PRIORITY, TIMER_STACK_SIZE);      _time_init_ticks(&LCDTicks, 0);   _time_add_sec_to_ticks(&LCDTicks, 30);//timer che scatta ogni 5 minuti e spegne il menu e ritorna al suo posto       _timer_backlight = _timer_start_oneshot_after_ticks( quit, 0, TIMER_ELAPSED_TIME_MODE, &LCDTicks);    }void restart_timer(void){ //unsigned long stato_timer = 0; _timer_cancel(timer_backlight); _time_init_ticks(&LCDTicks, 0); _time_add_sec_to_ticks(&LCDTicks, 30);//timer che scatta ogni 5  minuti e spegne il menu e ritorna al suo posto  timer_backlight = _timer_start_oneshot_after_ticks( quit, 0,TIMER_ELAPSED_TIME_MODE/*, &LCDTicks);}