/********************************************************************************/
/*Template code for External/Timer Interrupt*/
/********************************************************************************/

#include <p18f4550.h>

void chk_isr(void);   //HIGH priority ISR

/*The following lines of code perform interrupt vector relocation to work with the USB bootloader. These must be
used with every application program to run as a USB application.*/
extern void _startup (void);
#pragma code _RESET_INTERRUPT_VECTOR = 0x1000	//RESET INTERRUPT VECTOR Location

void _reset (void)
{
        _asm goto _startup _endasm
}

#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x1008	//HIGH INTERRUPT VECTOR Location
void high_ISR (void)
{
    _asm goto chk_isr _endasm    //ISR for handling high priority interrupts
}

#pragma code
#pragma code _LOW_INTERRUPT_VECTOR = 0x1018  //LOW INTERRUPT VECTOR Location
void low_ISR (void)
{
	
}
#pragma code

void Timer_start();		//Timer0 Initialization function declaration
void PortB_Change();    //PORTB ISR Initialization declaration
void  PORTB_ISR();		//PORTB ISR Handler declaration
void  Timer0_ISR();		//Timer0 ISR Handler declaration


#pragma interrupt chk_isr		//High Priority ISR
void chk_isr (void)
{
    //Check for external(PORTB) interrupt/timer interrupt flags
	//and call the corresponding Handler
}

      
//Main function
void main(void)
{   
	//Initialize PORTB GPIOs
	// Enable the weak internal pull-ups on PORTB
    
	//
    while(1)
	{
		
	}	
}


void PortB_Change()
{
    //Clearing Port B change interrupt flag 
    //Enabling Port B change interrupt
	// Global interrupt enabled
}


//Function to initialize Timer0
void Timer_start()
{
        //Set the timer to 16-bit mode,internal instruction cycle clock,1:1 prescaler
		//Reset TMR0H,TMR0L registers
        //Clear Timer0 interrupt Flag and enable Timer0 interrupt
		//Enable Global interrupt
		//Start the Timer0
		
		
		
}

//Timer0 ISR handler
void  Timer0_ISR()
{
    // Clear Timer0 overflow flag
    // Load values in TMR0H,TMR0L
    


}

//PORTB ISR Handler
void  PORTB_ISR()
{
	//Clear PORTB interrupt flag
	//Toggle output GPIO pins
	
	
}	