Hints for the Edu Interrupts

Hello all,

Since I’m a mentor I will not give you the answer as to how to get your interrupts running. However here is some usefull information:

  1. In the Microchip library there is a function called OpenPORTB, find out what is does and put it in your initialization code.

  2. When you are calling interrupts you need to “save the context”, there is a note about this in the PIC18F8520 datasheet on the Microchip site. However this is for people writing assembler, and the C code will not need this.

  3. You may not want to code a printf line into an interrupt. It is generally a bad idea in the embedded programming world. To test if the interrupt is working have it add 1 to a global variable. Put this line in your main.c outside the main function (line 23):
    int global_counter;

Put the printf in the main:
printf("Counter=%d
",global_counter);

Put this line in your user_routines_fast.c outside any functions (line 60):
extern int global_counter;

Put this code in the InterruptHandlerLow () function:
global_counter++;

When you run your program and close and open the Interrupts the count will increase.

-Jim Wright