pic_tick.c File Reference

Include dependency graph for pic_tick.c:

Functions

void handle_tick ()
 Call this routine to increment tick count.
uns16 tick_calc_diff (uns16 a, uns16 b)
 Calculate the tick time difference between two values.
uns16 tick_get_count ()
 Return current tick count.
void timer_0_callback ()
 Timer 0 callback function.

Function Documentation

void handle_tick (  ) 

Typically called during the interrupt routine of a timer to increment the tick count. Note this routine assumes that interupts are off - which is always the case in an interrupt sub routine.

00066                    {
00067    tick++;  // we assume that interrupts are off at this point
00068 }           

uns16 tick_calc_diff ( uns16  a,
uns16  b 
)

Calculates how many ticks have elapsed between two tick values. Covers cases where the tick count wraps beyond its 16 bit value.

00058                                        {
00059     if (a <= b) {   // simple case
00060         return b-a;
00061     } else {
00062         return 65535 - a + b + 1;   // more complex case
00063     }
00064 }

Here is the caller graph for this function:

uns16 tick_get_count (  ) 

Returns the current tick count. Thread and interrupt safe.

00047                        {
00048 
00049 uns16 result;
00050 
00051     start_crit_sec();
00052     result = tick;  // Grab a copy
00053             
00054     end_crit_sec(); // interrupts back to normal
00055     return result;  // return the result
00056 }   

Here is the caller graph for this function:

void timer_0_callback (  ) 

When a timer 0 interrupt occurs, after handling the interupt and timing issues, this callback function is executed. You will need to define this subroutine in your code, otherwise linking will fail.

00043                         {
00044     handle_tick_inline();
00045 }   

Here is the call graph for this function:


Generated on Fri Aug 19 09:08:50 2011 for Pic Pack Library by  doxygen 1.6.1