How to implement this schedule in FreeRTOS?

Hello, I have 6 ultrasonic sensors HC-SR04 which I want to trigger them accoding to the following schedule: Table attached. If you have further questions, you can see the paper related: https://www.cs.cmu.edu/~motionplanning/papers/sbppapers/integrated1/borensteinobstacle_avoid.pdf They will fire in groups of 2. First period: S1 (sensor 1) fires at 24 ms S2 = 49 ms S3=24 ms S4=49 ms S5=24 ms S6= 49 ms Second period: S1= 37 ms S2=75 ms S3= 39 ms S4=77 ms S5 = 41 ms S6 = 79 ms That’s the schedule, I mean, for the first period, first S1 fires at 24 ms, then S2 at 49 ms, so S2-S1 = 25 ms, so when S3 fires, it’s been 50 ms. After first period, S1 fires again but at 37 ms after sensor 6 in first period. Note that the shortest time difference between firings of any 2 neighboring sensors is 38.0 ms As you know, to trigger an ultrasonic sensor, a 10 us pulse needs to be sent to the trigger pin . The times above just mean the exact point when the get triggered. Hopefully you understand what I want to achieve using FreeRTOS. Do you think I should just create simple tasks with same priority and blocking time equal to the time needed to trigger the sensor?

How to implement this schedule in FreeRTOS?

The first big question is how accurate do those time marks need to be. My guess is fairly accurate. If that is so, then my guess is using tasks might not be good enough, but you want to trigger this in an interrupt. Depending on what else is happening in the system, you might be able to use a tick hook function to count of the time periods (looks like you need a 1 ms tick as the greatest common divisor for those time periods), or you might need to use some dedicated timer at a high priority to perform this sequencing. Hopefully you have a processor pin that you can program to give the 10us pulse, or that ISR will need to busy wait for that period, or if your processor is fast enough, have a second interrupt triggered for the turn off. If your timing margins are coarse enough to allow for tasks, then I would probably use timer callbacks for each sensor triggered to occur at the appropriate time.