>Method 1: >Let the piece of code stay within a while loop and make sure there are no >other processes that can interrupt it. >This could be bad because there may be other tasks that needs attention. This isn't really a good idea. If you let it be interruptible, it would be ok, but since it's supposed to be realtime, that's not good. >Method 2: >Create a timer that has the highest level of interrupt priority. This is a much nicer method. >Is there any C function within MPLAB C18 compiler that caters to real-time >processes? Ok, so you're using an 18-series PIC, which definitely makes it easier to implement this. I would recommend using the Tmr0 overflow to keep your real time thread happening. And make it a high priority interrupt. Try to keep your other high priority interrupts to a minimum. >As a general guideline, should the highest priority be assigned to those >"more important" routines with long execution time or to those routines >which can be executed to completion in the shortest time? You can debate over this a lot, I think it comes out to two different schools of thinking. --Brendan -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics