problems about time_delay

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

problems about time_delay

跳至解决方案
1,984 次查看
songwei
Contributor II

The  time_delay  will make a task pending, but it seems that  the task doesn't go on after that in my project.

for example:

    { 8,      task1,  1000,8,      "task1",MQX_AUTO_START_TASK,10,    10 },
{ 9,      task2,  1000,9,      "task2",MQX_AUTO_START_TASK,20,    10 },

static void task1( uint_32 initial_data )

{

    while(1)

    {

        printf("*");

        _time_delay(300);

    }

}

static void task2( uint_32 initial_data )

{

    while(1)

    {

        printf("-");

        _time_delay(500);

    }

}


the result is *- 

only once 

Does anyone know the reason? Thanks a lot!


What's more  if  use PE to make the configuration,it will report erorrs.So I use the Device Initialization to make the mcg code,and manually copy it to MQX ,after some test and changes ,it finally works. I am not sure it is the reason or not .

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,729 次查看
songwei
Contributor II

Hi,Huereca

Thanks a lot for your reply.

I just have worked out the _time_delay.

The reason is I have made the code about System timer initialization not work.

And now it can work correctly. :smileyhappy:

在原帖中查看解决方案

0 项奖励
回复
7 回复数
1,729 次查看
anthony_huereca
NXP Employee
NXP Employee

I tried copying and pasting your code in a project, and it worked as expected for me. So I'm curious as to what is going on. Have you tried just using one task with a _time_delay(500) in it? Or try _time_delay(5)? Which board/part is this on?

If you adjusted the BSP Tick Frequency and/or clocks, it may be causing the delay to be much longer than expected.Try waiting a really long time, you may see it print out again.

Also _time_delay() is a default feature in MQX, and is actually unrelated to the more robust Timer features. There is no need to include any extra header files or enable something in user_config.h to use _time_delay().

0 项奖励
回复
1,730 次查看
songwei
Contributor II

Hi,Huereca

Thanks a lot for your reply.

I just have worked out the _time_delay.

The reason is I have made the code about System timer initialization not work.

And now it can work correctly. :smileyhappy:

0 项奖励
回复
1,729 次查看
songwei
Contributor II

Anybody can help?

Thanks a lot ! :-)

0 项奖励
回复
1,729 次查看
drummer
Contributor IV

this is my template.

const TASK_TEMPLATE_STRUCT MQX_template_list[] =

{

    /* Task Index,   Function,   Stack,  Priority,    Name,       Attributes, Param,  Time Slice */

    {TELNET_TASK_ID, uTelnet_task,   1500, 10,         "nc500_Telnet" , 0, 0,      0 },

    {HTTP_TASK_ID,   uhttp_task,   1750, 7,         "http" , 0, 0,      0 },

    {ARCNET_TASK_ID, uArcnet_task,   512, 9,         "Arcnet" , 0, 0,      0 },

    {SOCKET_TASK_ID,   uSocket_task,   1000, 7,         "Socket" , 0, 0,      0 },

    {LIF_TASK_ID, uLif_task,   700, 10,         "Lif" , 0, 0,      0 },

    {FLASH_UP_TASK_ID, uFlash_Up_task, 1000, 10,         "Flash_up" , MQX_AUTO_START_TASK, 0,      0 },

  {VNC_TASK_ID, uVNC_task, 4500, 10, "VNC", 0, 0, 10 },

  {A2D_TASK_ID, uA2D_task, 660, 10, "A2D", 0, 0, 10 },

    {0, 0, 0, 0, 0, 0, 0, 0 }

};

Don't forget to leave a NULL record at the end.

I only use one MQX_AUTO_START_TASK. This task creates the  VNC  task once it is satisfied it doesn't have to upgrade.

   _task_create(0, VNC_TASK_ID, 0);

VNC task starts up the other tasks as required.

0 项奖励
回复
1,729 次查看
songwei
Contributor II

Hi,Bourgeois!

Thanks a lot for your reply.

You mean we can create task through _task_creat  in a auto_start_task.

I think it's a good idea.

I also use the interrupt and lwsem to activate a task.

What's more, do you know how to configure the user_configure.h and the task code to use the timer in MQX?

0 项奖励
回复
1,729 次查看
JerryFan
NXP Employee
NXP Employee

Very likely that the timer used for _time_delay_ was not initialized properly. Please double check it.

0 项奖励
回复
1,729 次查看
songwei
Contributor II

Hi Fan!

Thank you very much for your reply.

You mean something wrong with the initialization?

What should I do besides adding  #include <timer.h> ?

0 项奖励
回复