creating periodic and aperiodic tasks

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

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

varad@1994
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.

Thanks!!
Regards,
Varad Diwakar

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: creating periodic and aperiodic tasks

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

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

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 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.

Mike


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 19 guests