creating periodic and aperiodic tasks

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

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

Posts: 6
Joined: Sat Jun 06, 2020 3:23 pm

creating periodic and aperiodic tasks

Postby varad@1994 » Thu Jun 18, 2020 2:27 pm

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.

Varad Diwakar

User avatar
Site Admin
Posts: 12871
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 717 times
Been thanked: 596 times

Re: creating periodic and aperiodic tasks

Postby Giovanni » Thu Jun 18, 2020 3:03 pm


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: ... _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.


Posts: 125
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 13 times
Been thanked: 19 times

Re: creating periodic and aperiodic tasks

Postby mikeprotts » Thu Jun 18, 2020 5:28 pm

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.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 4 guests