So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By HEck
#81808 Hi btidey,

yes, you´re right. I`m using the non-os compiler from Espressif. When I started with the ESP8266, I used Arduino too. But I could see, in this environment is the time between the GPIO-interrupt trigger and ISR-start higher. And sometimes the ISR execution time is sometimes longer, so that the syncronization between MasterClock and Slave was lost. In the SDK of Espressif is this behavior quite better. I want to avoid a Slave-Clock-Streching and decide to use this development tool.

But unfortunately the dokumentation which I could find on the Espressif site is not sufficient - at least for me. I was spoiled by Microchip ;)

Seems I have to study it more deeply;-)

Thank you for yor support.
Greetings
Henry
User avatar
By quackmore
#81810 have a look to the "code structure" chapter inside the non_os_sdk_api_reference
the non_os_sdk is not really an os so don't use any main loop but try one of following

using a task (sort of):
Code: Select all#include "user_interface.h"
// define a task function (ie inside user_init)
static void ICACHE_FLASH_ATTR your_task(os_event_t *e)
{
    switch (e->sig)
    {
    case SIG_FINISHED:
        // do whatever you need to do
        break;
    default:
        break;
    }
}

..

// setup the task at start-up (ie inside user_init)
os_event_t your_queue[QUEUE_LEN];
system_os_task(your_task, USER_TASK_PRIO_0, your_queue, QUEUE_LEN);

...
// inside your ISR instead of setting the flag use
system_os_post(USER_TASK_PRIO_0, SIG_FINISHED, '0');


or use a timer to perform periodic checks

Code: Select all// define a timer callback
static void ICACHE_FLASH_ATTR your_timer_cb(void)
{
    // do your periodic checks
}

// setup the timer

#include "osapi.h"

os_timer_t your_timer;
os_timer_disarm(&your_timer);
os_timer_setfn(&your_timer, (os_timer_func_t *)your_timer_cb, NULL);
os_timer_arm(&your_timer, period_in_milliseconds, 1);
User avatar
By HEck
#81811 Hi quackmore,

your example was very helpful. In the document is not a direct pointer for the relationship between "system_os_task" and "system_os_post", which is really needed to understand this functionallity.

Thank you for your support.
Greetings
Henry