Page 1 of 1

creating periodic and aperiodic tasks

Posted: Thu Jun 18, 2020 2:27 pm
by varad@1994
Hello ,
I recently started working on ChibiOS. I can create a simple in ChibiOS . But now I wanted to create a periodic task which will activate at a certain period (500ms) then how can I do it in ChibiOS.
And one more thing I wanted to ask, about aperiodic task I wanted create a application where I have two Tasks ,one is periodic task activates at every 500ms and inside that I will check for a condition (lets say sensor input) if it is satisfies then I want to activate my a periodic tasks. Then how I can implement this application.
Can you please help me to design this application.

Thanks!!
Regards,
Varad Diwakar

Re: creating periodic and aperiodic tasks

Posted: Thu Jun 18, 2020 3:03 pm
by Giovanni
Hi,

All tasks are the same in ChibiOS, you can do periodic or aperiodic operations inside thread functions.

There are examples for periodic tasks in the book here: http://chibios.org/dokuwiki/doku.php?id ... _threading

Look at the 3 solutions for "fixed intervals".

Your periodic task could terminate when not needed and be restarted by the aperiodic task. Alternatively you can have it waiting on a semaphore, there are several possible solutions for this.

Giovanni

Re: creating periodic and aperiodic tasks

Posted: Thu Jun 18, 2020 5:28 pm
by mikeprotts
Depending on your sensor, you could have a thread suspended with timeout (chThdSuspendTimeoutS), and have the sensor interrupt wake the thread (chThdResumeI). You can then process according to either timeout (MSG_TIMEOUT) or interrupt condition.

Mike