I was wondering if there is anyone that can help me with creating a delay function for the 5213 that can be used by several tasks, and be able to interrupt each other. I am in need of a single function that can be used to delay the system for a given number of microseconds. I have tried to create this by using the DMA timers (there is a function that freescale gave, but it only can be run by 1 function), and i modified it to check to see if the specific timer is in use, and if it is, skips to the next one. i was hoping this would work, but sometimes the system will hang within the my_pause() funciton, waiting for the timer to run over.
I cannot use different functions, really, either, because of the fact that any order of interrupts may trigger, so it would be impossible to assign each isr to use a different timer. also, i tried a while back to implement this using a queue (dynamic memory allocation) and 'semaphores', but that didn't work (though it worked on a windows machine, compiled with visual c++), so i am out of ideas.
Does anyone have anything that i might be able to use, or any hints as to where i can go with this?!
I have attached the code that i thought would work below: