task loop

ali.nasr
Posts: 4
Joined: Sun Oct 25, 2015 6:48 pm

task loop

Postby ali.nasr » Sun Nov 01, 2015 11:04 pm

hi
i want to do somthing in a loop like this code.

Code: Select all


pwm_1Task(os_event_t *events){
    os_delay_us(10000);
   pwm_motor1_adjust();
   os_delay_us(10000);
    system_os_post(pwm_1TaskPrio, 1, 1 );
};


void user_init(void)
{
    at_init();
    at_port_print("\r\nready\r\n");
    at_cmd_array_regist(&at_custom_cmd[0], 1);
       system_os_task(pwm_1Task, pwm_1TaskPrio, pwm_1TaskQueue, pwm_1TaskQueueLen);
       system_os_post(pwm_1TaskPrio, 1, 1 );
   


pwm task working well in a loop, but wifi and AT commands not working!!!!!
generally how can i use a loop in esp8266 . for example i want to read sensors data and then adjust the light or motor rpm with that date in a Infinite loop whit wifi and AT commands working.
how can i do that????!!!

User avatar
kolban
Posts: 131
Joined: Tue Jun 16, 2015 1:09 pm
Location: Fort Worth, Texas, USA

Re: task loop

Postby kolban » Mon Nov 02, 2015 10:52 pm

At a guess, I am presuming you are starving the operation of the AT command processor. Rather than immediately sending in a request to start a new task at the immediate completion of the previous task, consider registering a timer that fires some period later ... when the timer fires, that would then be the signal to post a task for execution. By introducing a delay, you are giving the rest of the environment an opportunity to do so alternative work.

Other ideas might be to find a "priority" of your own task that is lower than the priority of other work ... so that if there is contention in "Do you work vs do other work", the other work will win.

ali.nasr
Posts: 4
Joined: Sun Oct 25, 2015 6:48 pm

Re: task loop

Postby ali.nasr » Tue Nov 03, 2015 5:27 pm

thanks kolban for your reply and your help
i creat the task and arm the timer and set function for that to call my task every 1ms and it works.now my loop and wifi works :D
but here i have 2 questions
1-now i am using that code in sdk 0.9.5 and my task and wifi working well but when i use exactly same code in sdk 1.3.0 or 1.4.0 esp reset every time and show this massage :
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 1396, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4
tail 8
chksum 0xc0
csum 0xc0

2nd boot version : 1.4(b1)
SPI Speed : 40MHz
SPI Mode : QIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

why it happens? and is there any problem to use sdk 0.9.5?because my cods are working well in sdk 0.9.5.should i fix that problem in sdk 1.3.0 and use this version?

2-you said :
Other ideas might be to find a "priority" of your own task that is lower than the priority of other work ... so that if there is contention in "Do you work vs do other work", the other work will win.

we have just have 3 prioruty 0/1/2 and what is your mean to find my task priority? i set my task priority to 2 .

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: task loop

Postby ESP_Faye » Wed Nov 04, 2015 2:28 pm

Hi,

In your case, it seems some tasks in the SDK of which priority is lower than your task can not execute.

Please use ets_task and ets_post instead of system_os_task and system_os_post.

Thanks for your interest in ESP8266 !

ali.nasr
Posts: 4
Joined: Sun Oct 25, 2015 6:48 pm

Re: task loop

Postby ali.nasr » Wed Nov 04, 2015 5:46 pm

we have just 3 choice 0/1/2 i test all of them in sdk 1.3.0 and i used ets_task ,ets_post no change!! and again it reset every 1 sec(rst cause=2)

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: task loop

Postby ESP_Faye » Wed Nov 11, 2015 3:19 pm

Hi,

Sorry that we can not duplicate your problem.

Here is our test code and test bin files, please have a try.

Thanks for your interest in ESP8266 !
Attachments
test_bin.zip
(198.15 KiB) Downloaded 640 times

Who is online

Users browsing this forum: No registered users and 26 guests