[Ovmsdev] Higher resolution events

HONDA S-2000 s2000 at audiobanshee.com
Wed Jan 10 10:26:52 HKT 2018


On Dec 2, 2017, at 1:46 AM, Tom Parker <tom at carrott.org> wrote:
> On 27/11/17 00:42, Mark Webb-Johnson wrote:
>> You definitely don’t want to be spinning - that won’t give you any precision on the delay (other tasks may pre-empt), and is also wasteful.
>> 
>> How about a timer (xTimerCreate). Have it fire once every 50ms/100ms. You can xTimerStart start it, and stop when done.
> 
> This worked! I create the timer once, start it whenever I receive the command, and stop it from within the timer call when I'm done.
> 
> I've got a bit more testing to do before I push, and I'd like to get the other leaf pull request out of the way first the remote command changes build on that change.

Naive question here: Does creating a timer use up a finite resource? What if other modules or commands need timers? Is there a risk that xTimerCreate will fail for some other part of the code while you’re holding on to your timer?

I ask because perhaps it would be better to create the timer when you receive a command, and release or free the timer when you’re done. Of course, if your command is always being sent periodically, then it may not matter whether the timer resource is made available for those brief windows in between repetitions.

It seems that modern ARM chips have lots of timer resources, but they’re still finite.

Yes, I realize that this is a basic memory-versus-speed tradeoff in efficiency. There’s not necessarily anything wrong with creating a resource once and then reusing it forever - I’m just wondering about the ramifications.

Brian




More information about the OvmsDev mailing list