inter1.c
Minimal PIC16F877 application that uses interrupts and watchdog.
//This sample program shows how to use interrupts.
//If there is a LED connected to B7 it will blink
//with a period of 65 ms
// Author : Joan Ilari - e-mail: c2c@ilari.org
#pragma CLOCK_FREQ 4000000
//------------------------------------------------
void interrupt( void )
{
PORTB ^= 0x80; // complement PORTB:7
clear_bit(INTCON,T0IF); // clear TMR0 overflow flag
}
//------------------------------------------------
main()
{
OPTION_REG = 7; // set prescaler to 1:256
clear_bit(TRISB,7); // set PORTB:7 as OUTPUT
enable_interrupt( GIE ); // enable interrupts
enable_interrupt( T0IE ); // enable TMR0 overflow bit
while(1)
{
clear_wdt();
}
}
Copyright© 2002 Pavel Baranov