#include #include #include #include #include #include #include /* Set configuration bits for use with ICD2 / PICDEM2 PLUS Demo Board: * - set HS oscillator * - disable watchdog timer * - disable low voltage programming */ #pragma config OSC = HS #pragma config WDT = OFF #pragma config LVP = OFF #pragma udata int ovrflw_count=0; /*global variable*/ #define CLEAR_DISPLAY 0x01 void DelayFor18TCY(void); void DelayPORXLCD(void); void DelayXLCD(void); void clear_lcd(int line); void low_isr(void); void high_isr(void); #pragma code low_vector=0x18 void interrupt_at_low_vector(void) { _asm GOTO low_isr _endasm } #pragma code /* return to the default code section */ //#pragma interruptlow low_isr save=PROD /* * Low Interrupt Subroutine */ void low_isr(void) { ovrflw_count++; INTCONbits.TMR0IF = 0; return; } /* * MAIN */ void main (void) { unsigned long int tmr; int i; char data_tmr[32]; char data_count[6]; TRISB=0b00000010; PORTB=0; TRISC=0b00000110; OpenXLCD(FOUR_BIT & LINES_5X7); // Init the LCD Display while(BusyXLCD()); WriteCmdXLCD(DON&CURSOR_OFF&BLINK_OFF); WriteDataXLCD('6'); while (PORTCbits.RC1==0); /*wait for signal from transmitter*/ PORTB=4; OpenTimer0( TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_1 ); INTCONbits.GIE = 1; while (PORTCbits.RC2==0); /*wait for signal from reciever*/ CloseTimer0; tmr = ReadTimer0(); OpenXLCD(FOUR_BIT & LINES_5X7); // Init the LCD Display while(BusyXLCD()); WriteCmdXLCD(DON&CURSOR_OFF&BLINK_OFF); WriteDataXLCD('3'); ultoa(tmr,data_tmr); itoa(ovrflw_count,data_count); for (i=0;i