Need advice for a beginner

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Need advice for a beginner

ソリューションへジャンプ
1,272件の閲覧回数
Rox
Contributor II

Hi, guys.

I just started working with operating systems. And MQX is my first one.

Recently I learned to do some simple things with the help of examples and application notes. It's an exciting process :smileyhappy:

And I have one question. What is the best way to organaize regular execution of task every 1 ms (its execution time is about 150us)? I tried to do that in such way:

if (_timer_create_component(7, 1500) != MQX_OK) printf ("  Timer initializing error\n");else printf(" Timer initialize\n");_time_init_ticks(&ticks, 0);_time_add_msec_to_ticks(&ticks, 1);//_time_add_sec_to_ticks(icks, 1);SPI_timer = _timer_start_periodic_at_ticks(led_driver_task, 0, TIMER_ELAPSED_TIME_MODE, &ticks, &ticks);

It's work fine only when i use the seconds/(hundreds of ms) as a period. :smileyfrustrated:

And in such way: 

task(){  while(1){    my_function(&trans_matrix[0][0][0]);    _time_delay(1);  }}

How would you have done this in my place? 

 

Regards, Rasul

 

P.S. How is my English? :smileyhappy: Is it too many mistakes here?

0 件の賞賛
返信
1 解決策
981件の閲覧回数
Rox
Contributor II

I did it.

Using ISR from second timer MTIM2.

I think it is a best decision.

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
981件の閲覧回数
Rox
Contributor II

Hi again!

My problem was solved by following change in the MQX source code:

 

 

uint_32 _mcf51CN_timer_init_freq (........){  ............  // calculating prescale and rate  ............  /* set registers */  /* mtim_ptr->MTIMCLK = ((uint_8) prescale);   mtim_ptr->MTIMMOD = (uint_8) rate - 1;   mtim_ptr->MTIMSC = MCF51XX_MTIMSC_TRST_MASK | (unmask_timer ? MCF51XX_MTIMSC_TOIE_MASK : 0); */  mtim_ptr->MTIMCLK = 0x07;       // this value and value below are manualy calculated with process expert  mtim_ptr->MTIMMOD = 0xF3;   mtim_ptr->MTIMSC = MCF51XX_MTIMSC_TRST_MASK | (unmask_timer ? MCF51XX_MTIMSC_TOIE_MASK : 0);}

My project is already finished, and it works fine. :smileyhappy:

But I noticed that some timer functions like _time_delay() didn't worked properly. Generated time durations was changed. This is not a critical issue for my project.

And I understand that this is because of my change of MQX source code. 

So my question: Can this change cause any other problems except described above?

 

Any answer would be greatly appreciated!!


MQX 3.6 was used. 

 

Regards.

 

 

 

 

 

0 件の賞賛
返信
982件の閲覧回数
Rox
Contributor II

I did it.

Using ISR from second timer MTIM2.

I think it is a best decision.

 

 

0 件の賞賛
返信