/* * EE 361L * Interrupt, Sleep and Watch Dog Timer example * * It has a single interrupt INT, and keeps track * of the number of interrupts (so far) in a global * variable "count". It continously outputs pulses * that have duration that is proportional to the * value of count. Thus, these pulses get longer * each each interrupt. * */ #include #define LEDport RB1 // RB1 is connected to the LED unsigned char count; // Global variable count (a byte) main(){ unsigned char i; TRISB = 1; // All PORTB are output ports, except RB0/INT // RB0/INT should be an input for the interrupt // signal. LEDport = 1; // Initialize the LED to off count = 1; // Initialize count; PSA = 1; // Post scalar used with Watch Dog Timer PS2 = 0; // Rate is 1:2. PS1 = 0; // Time out is approx 2 x 18 ms = 36 ms PS0 = 1; INTEDG = 1; // Interrupts are pos edge triggered INTCON = 0; // Disable all interrupts but.. INTE = 1; // Enable the INT interrupt INTF = 0; GIE = 1; // Allow interrupt signals while(1) { for (i=0; i