#include <system.h>
#ifdef _PIC16F877A
#pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC & _LVP_OFF
#endif
#pragma CLOCK_FREQ 20000000
void Test(void);
void inter_set();
void main()
{
inter_set();
while(1) { }
}
void inter_set()
{
portb = 0x00;
trisb = 0x01;
set_bit( option_reg, INTEDG ); // Set for rising edge
set_bit( intcon, INTE ); // Enable external interrupt
set_bit( intcon, RBIE ); // RB change interrupt
set_bit( intcon, GIE ); // Set global interrupt
}
void interrupt(void)
{
if(INTF) // External interrupt, button RB0 has been pressed
{
Test();
clear_bit( intcon, INTF ); // clear the interrupt
}
}
void Test(void){
porte.0 = 1;
delay_10us;
}