Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timer Tasks

Status
Not open for further replies.
I was going through a project in which a periodic interrupt timer is set up for 10ms.Now tasks for 20ms, 50ms, 100ms, 200ms are setup with each taking certain amount of time to execute. If 10ms interrupt happens for 2 times then 20ms is over, certain activities are performed in 20ms, which will take x ms.Now let us say 10ms happens for 10 times then it will be both 20ms(20ms *5) and 100ms which one will execute? Similarly for 20ms, 100ms, 200ms the tasks may overlap. Is it the standard way to do it? Any other methods are available where the tasks don't overlap? The above tasks are round robin. Please advise.
 
I would do it the same way... you can have "task timer variables" that count to 2, 5, 10 and 20... But you will need a "task priority" mechanism.. If the interrupt is at 200mS you would have all 5 tasks requiring service... So!!! 10mS and 20S can be serviced within the interrupt and the 50mS, 100mS and the 200mS can be serviced outside the interrupt..

It also depends on how long each task takes... ie.. If the 10mS task take 10mS.. NOTHING else will get done...

Maybe this is a job for an RTOS ( Real Time Operating System).. there are free ones available...
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top