Electronics > Microcontrollers

Quick ESP32 project - Arduino, ESP IDF, Micropython, Tasmota?

<< < (5/5)


--- Quote from: Geoff-AU on December 06, 2022, 10:33:29 am ---Arduino (usually) sucks majorly trying to do 3 different jobs on the same microcontroller.

--- End quote ---
I have had no problems using  FreeRTOS with Arduino, with 18 tasks running updating info for an LCD.
This book provides a good way in:

I'm still enjoying my love/hate relationship with manually coding my buffer and task synchronisation.  Well, caveat, I am on single core MCUs.  I expect I will get bored of that and it will become a chore.  So RTOS is on the list to get round to exploring.  Buffer/task synchronisation between cores really requires careful ASM coding or... using some form of OS based IPC support... which is ESP32 IDF/Arduino's approach.  Semaphores, queues, mutexes etc.

It's been a long while since I studied low level distributed IPC, but there has to be atomic test+set instructions, cache invalidation and such to ensure correct synchronisation.   Best left to something like a microkernel.

EDIT:  I wonder if ARM architecture's "conditional statement variants" could be atomic enough to provide test+set operations.  My worry would be they would only be register level operations and not memory based, making the synchronisation a lot more difiicult as cores don't share registers.

The C code such as:

_lock = get_mutex(thing);
if ( _lock != NULL ) {}

Or aggressively
while( NULL == get_mutex(thing) ) {}

can be implemented in get_mutex as a test+set operation.  In one atomic instruction the memory address will be tested (is it already locked) and immediately set if it's found in a certain state (not already locked).  Such that the return in C land is a pointer to your hold on the mutex or a NULL if it was found to be already locked.  It does not matter how many cores or CPUs or PCs in a cluster attempt to do the same thing at the same time, the test+set atomic instruction will mean only one of them gets the lock.


--- Quote from: james_s on December 07, 2022, 12:39:22 am ---
--- Quote from: Geoff-AU on December 06, 2022, 11:45:20 pm ---My point is, the Arduino ecosystem is great right up until you spend a bunch of time fighting with libraries because you've blown your timing budget.  That's usually a very complex sketch though, and now that the SAMD21 and ESP32 processors are cheap and fast you can waste a lot of cycles on sinful programming shortcuts and still have enough headroom to be OK.  Arduino lets you be lazy, and fast MCUs let you be even lazier.

Haven't seen TaskManagerIO specifically but there are a ton of schedulers out there that do similar jobs.

--- End quote ---

Arduino has plenty of warts for sure, but "x is great right up until you spend a bunch of time fighting with y because you want to do z" can apply to virtually every embedded platform.

--- End quote ---
Exactly! That’s the point I was trying to make.


[0] Message Index

[*] Previous page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod