[TriEmbed] Arduino FreeRTOS ESP32 project - protecting timing-sensitive code

triembed at matrixwide.com triembed at matrixwide.com
Fri Jan 24 09:02:51 CST 2020


Pete,

I just caught my clock taking a pause in the display update, presumably while it fetched a weather update. Somewhere there’s a library using a delay() or in a blocking loop which is blocking my display thread, despite pinning.

Grrrr.

> On Jan 24, 2020, at 8:33 AM, Mike Lisanke <mikelisanke at gmail.com> wrote:
> 
> Ok, thanks for the clarification. 
> 
> On Fri, Jan 24, 2020 at 7:57 AM <triembed at matrixwide.com <mailto:triembed at matrixwide.com>> wrote:
> On ESP boards in Arduino you get freeRTOS built-in (no need to include anything). I guess this is because the Espresstif libraries include it.
> 
> I’m mainly concerned with the scheduler not interrupting the character sending process for the HD44800 LCD. So far it seems a 'vTaskDelay(1);’ in each thread has things working well. Mutex would usually be to lock a shared resource but I was considering it just as way to stop other threads while the LCD is written.
> 
> Alex
> 
>> On Jan 24, 2020, at 7:43 AM, Mike Lisanke <mikelisanke at gmail.com <mailto:mikelisanke at gmail.com>> wrote:
>> 
>> It's been my understanding that Arduino is single threaded (except for their own interrupt handling) and that single use resources could be handled in your user code (the main loop) anywhere without conflict (multi-use) because you would naturally structure the code to use a resource (and clean up) then use the resource again... If you're doing your own threading model then it would benefit us to understand What you've implemented to split your tasks among many cycles of the main loop. I just googled and it doesn't appear that Arduino has a multi-tasking component of its loop But of course there are many open source extensions to the basis setup. 
>> 
>> Are you primarily concerned with common use of the I2C bus? Is you "mutex" just a bit/byte/word of memory that you're in a stream to an external device and need to complete it? Or, does mutex imply you have a supervisor interpreting the availability of a resource and selecting whether or not to "dispatch" a thread (section of code) to execute based on the resource availability?
>> 
>> On Thu, Jan 23, 2020 at 5:51 PM Alex via TriEmbed <triembed at triembed.org <mailto:triembed at triembed.org>> wrote:
>> I’m working on a time and weather forecast clock based on an ESP32 and a 20x4 HD44800 LCD connected via an I2C port expander thing. I’m ‘cheating’ at the moment by splitting the display update code and the weather-fetch code into two tasks and pinning them to separate cores.
>> 
>> I think the right way to do this is to protect the LCD at the character-sending level with a mutex, but I dread what I may find in terms of how they have overloaded the usual Arduino print and println functions. I should probably also replace my global ‘locking’ access to the network with a mutex, since NTP and the weather updates could clash.
>> 
>> Anyone already do something similar to this who would like to share code?
>> 
>> Thanks,
>> Alex
>> _______________________________________________
>> Triangle, NC Embedded Computing mailing list
>> 
>> To post message: TriEmbed at triembed.org <mailto:TriEmbed at triembed.org>
>> List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org <http://mail.triembed.org/mailman/listinfo/triembed_triembed.org>
>> TriEmbed web site: http://TriEmbed.org <http://triembed.org/>
>> To unsubscribe, click link and send a blank message: mailto:unsubscribe-TriEmbed at bitser.net <mailto:unsubscribe-TriEmbed at bitser.net>?subject=unsubscribe
>> 
>> 
>> 
>> -- 
>> Best regards,  Mike
> 
> 
> 
> -- 
> Best regards,  Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20200124/6ddd188f/attachment.htm>


More information about the TriEmbed mailing list