[TriEmbed] ESP8266 Programming tip

Rodney Radford ncgadgetry at gmail.com
Wed Jan 27 14:55:37 CST 2021


I just looked at the Ticker library routines and they are only a few lines
and basically a wrapper around os_timer_arm which is supposed to have 1 ms
accuracy, plus or minus 1ms.

Arduino/Ticker.cpp at master · esp8266/Arduino (github.com)
<https://github.com/esp8266/Arduino/blob/master/libraries/Ticker/src/Ticker.cpp>

The os functions are documented here:

2c-esp8266_non_os_sdk_api_reference_en (espressif.com)
<https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf>

Three is also an os_timer_arm_us that is supposed to be accurate to 500us
(so basically 0.5 ms) so it doesn't really get you much better resolution

But it should be accurate enough for most operations as long as you keep
your interrupt handlers short/simple


On Wed, Jan 27, 2021 at 3:34 PM John Vaughters via TriEmbed <
triembed at triembed.org> wrote:

> Mike,
>
> >An example might be strcpy.  It's several assembly instructions long.  So
> when the timer runs out, we don't know the status of that copy.
>
> In the case of an interrupt, this example makes perfect sense. In the case
> of using millis() or micro() to schedule a turn, this is not clear to me.
> Maybe I am over-simplifying it and I certainly have not spent the time to
> review the library code. But if code is moving along, and the scheduled
> time frame passes to execute but the current action is progress, it would
> wait for that code to complete before moving to the next step. And so we
> are not dealing with any sort of context switch at all, just waiting our
> turn to execute once the program reaches our place in line. Hence my
> comment that we may be dealing with sequential programming. To me I am left
> wondering exactly what the Ticker lib does, but not so willing to take that
> time to figure it out. There are definitely conflicts to my simplified
> belief. Maybe one day I will investigate further. For sure your input has
> helped me understand the Watchdogs more.
>
> The new timer arrangement went about a day with zero communication errors
> and that is an improvement. I even reduced the response timeout to modbus
> comms and still no issue. that is better than when I was using the delay,
> which had a 3-5 errors a day with a longer modbus response timeout. That
> could also just be a fluke in good wifi connections, but it does seem
> better and the responsiveness of the code certainly was improved by taking
> out a guaranteed 25ms delay.
>
> I appreciate everyone's efforts in helping explain this ESP product, I
> learned alot in the past week or so on this little board. I really like it.
> So cheap relative to the capabilities. I wish I wouldn't have waited this
> long. `,~)
>
> Thanks,
>
> John Vaughters
>
> _______________________________________________
> Triangle, NC Embedded Computing mailing list
>
> To post message: TriEmbed at triembed.org
> List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> TriEmbed web site: http://TriEmbed.org
> To unsubscribe, click link and send a blank message: mailto:
> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20210127/09d01ef2/attachment.htm>


More information about the TriEmbed mailing list