Problem With TIMER COMPONENT MCF52259EVB

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problem With TIMER COMPONENT MCF52259EVB

跳至解决方案
1,095 次查看
Britti1982
Contributor I

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);}

 

0 项奖励
回复
1 解答
823 次查看
PetrM
Senior Contributor I

Hello,

 

_timer_cancel() function deallocates your timer only when called from the same task that created the timer component.

 

PetrM

 

在原帖中查看解决方案

0 项奖励
回复
1 回复
824 次查看
PetrM
Senior Contributor I

Hello,

 

_timer_cancel() function deallocates your timer only when called from the same task that created the timer component.

 

PetrM

 

0 项奖励
回复