#include <pic.h>
// fuses configuration
// watchdog timer off, unprotect code, powerup timer on, high speed crystal/resonator
__CONFIG(WDTDIS & UNPROTECT & PWRTEN & HS);
//----------
static void setUp(void)
//----------
{
//global settings
GIE = 1; // enable global interrupts
EEIE = 1; // enable ee write complete interrupts
// port B setup
PORTB = 0;
RBIF = 0; // clear PORTB interrupt flag
RBIE = 1; // enable interrupt on change
RBPU = 1; // set weak pull-ups 0=On,1=OFF
// set PORTB pins 4,5,6,7 as input pins
TRISB = 0b11110000;
// port A set-up
TRISA = 0b00000;
PORTA = 0;
//TMR0 setttings
T0IF = 0; // clear the interrupt flag
T0IE = 0; // disable interrupt
}
//----------
void FooDelay(unsigned char counter)
//----------
{
unsigned char i;
unsigned char k;
do {
i = 4;
do {
k = counter;
do {
} while(--k);
} while(--i);
} while(--counter);
}
//----------
main()
//----------
{
setUp(); // set-up the machine
while(1) { // go now into an endless loop
FooDelay(250);
PORTB ^= 10;
FooDelay(250);
}
}