pic_timer1.h File Reference

Timer 1 support. More...

Include dependency graph for pic_timer1.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TIMER1_PRESCALER_1_TO_2   0b00010000
#define TIMER1_PRESCALER_1_TO_4   0b00100000
#define TIMER1_PRESCALER_1_TO_8   0b00110000
#define TIMER1_PRESCALER_OFF   0b00000000

Functions

void timer_1_callback ()
 Timer 1 callback function.
void timer_handle_1_isr ()
 handle timer 1 in interrupt service routine
void timer_setup_1 (uns8 prescaler_setting, uns16 timer_start_value)
 Setup timer 1 with starting values.
void timer_start_1 ()
 Start timer 1.
void timer_stop_1 ()
 Stop timer 1.

Variables

uns16 timer_1_start_value

Detailed Description


Define Documentation

#define TIMER1_PRESCALER_1_TO_2   0b00010000
#define TIMER1_PRESCALER_1_TO_4   0b00100000
#define TIMER1_PRESCALER_1_TO_8   0b00110000
#define TIMER1_PRESCALER_OFF   0b00000000

Function Documentation

void timer_1_callback (  ) 

When a timer 1 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.

Here is the caller graph for this function:

void timer_handle_1_isr (  )  [inline]

Call this routine in your interrupt subroutine to automatically service timer 1 interrupts if they have occursed.

00094                                  {
00095     uns16 start_value;  
00096     if (test_bit(pir1, TMR1IF)) {   // interrupt?
00097         #ifdef _PIC16
00098             start_value = tmr1l + timer_1_start_value  + 8; // adjust start value
00099             tmr1h = start_value >> 8;   // set high value
00100             tmr1l = start_value & 0xff; // set low value (must be done in this order)
00101         #else
00102             start_value = tmr1l + timer_1_start_value  + 8; // adjust start value
00103 
00104             tmr1h = start_value >> 8;   // set high value
00105             tmr1l = start_value & 0xff; // set low value (must be done in this order)
00106         #endif
00107         timer_1_callback(); // call the callback
00108         clear_bit( pir1, TMR1IF ); //clear timer 0 interrupt bit
00109     }
00110 }   

Here is the call graph for this function:

void timer_setup_1 ( uns8  prescaler_setting,
uns16  timer_start_value 
)

Turns off timer 1, sets prescaler setting and start value (which will be loaded on each reset).

00043                                                                     {
00044 
00045     clear_bit(t1con, TMR1ON);   // turn off timer if it was on so we can get it set up
00046     clear_bit(t1con, TMR1CS);   // Internal instruction cycle clock
00047     #ifdef _PIC18
00048         set_bit(t1con, RD16);
00049     #endif  
00050     t1con &= 0b11001111;
00051     t1con |= prescaler_setting;
00052     timer_1_start_value = timer_start_value;
00053     set_bit(pie1, TMR1IE);  // Turn on timer 0 interrupts
00054 }

void timer_start_1 (  ) 

Kicks off timer 1.

00056                      {
00057     tmr1h = timer_1_start_value >> 8;
00058     tmr1l = timer_1_start_value & 0xff;
00059     set_bit(t1con, TMR1ON);
00060 }

void timer_stop_1 (  ) 

Stops timer 1.

00063                     {
00064     clear_bit(t1con, TMR1ON);
00065 }


Variable Documentation


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