chibios_rt::Timer

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Has thanked: 15 times
Been thanked: 24 times

chibios_rt::Timer

Post by Thargon »

Hi guys,

I'm trying to implement some state machine like behaviour and would like to use a timer to trigger an upcoming state.
I just want to wait for some time and then trigger an event for one specific thread (no broadcast).

Since evereything else is done in C++, I would prefer to use the provided C++ class chibios_rt::Timer.
Unfortunately, all member function of that class are I-Class API functions and I can't get them to work.
If I don't use chSysLock() and chSysUnlock() I get the SV#10 error (misplaced I-class function) as expected.
But when I try to lock the system via chSysLock() I get the SV#4 error (misplaced chSysLock()).

Since I can't find any example on the net how to use the Timer class, maybe someone of you can provide some help :)

Thanks in advance!

Thargon
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chibios_rt::Timer

Post by Giovanni »

Hi,

SV#4 means that you call chSysLock() twice, use the debugger stack trace and see where this happens.

Giovanni
Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Has thanked: 15 times
Been thanked: 24 times

Re: chibios_rt::Timer

Post by Thargon »

Hi,

thanks for your quick reply.

If that was the case, why do I get SV#10 without chSysLock()?

Maybe I don't understand the locking system yet, but I can't find a good explanation in the documentation.
The documentation just states
Function Class:
Special function, this function has special requirements see the notes.

So far I was unable to find these notes.

Thargon
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chibios_rt::Timer

Post by Giovanni »

Hi,

Read the "Kernel Concepts" section into the general documentation, classes are described there.

http://chibios.sourceforge.net/html/concepts.html

Giovanni
Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Has thanked: 15 times
Been thanked: 24 times

Re: chibios_rt::Timer

Post by Thargon »

Hi again,

thanks for the link, though it didn't help me in this particular case :(

I don't have a dev board at hand right now, so I cant use the debugger stack trace.

What I just did, was to read the dbg_lock_cnt and isr_lock_cnt variables (which seem to be relevant for the SV#4 error) just before I call chSysLock(). Both are 0, though I can't guarantee that nothing happens between the two calls.

Any further Ideas or examples?

Thank you for your help!

Thargon
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chibios_rt::Timer

Post by Giovanni »

If both variables are set to zero then you should not get that SV#4, it is hard for me to imagine what could be wrong there if you don't inspect with a debugger.

You need to single step through it and see which check fails.

Giovanni
Post Reply