The next thing to do is to initialize the interrupt service routine and also to configure the change on Port B interrupt. By referring to the interrupt that is used by the original demo to calculate the ticks for the blinking LED for the TCP/IP stack, it seems that is necessary to set the global interrupt enable pin, set the interrupt priority enabled pin, low priority interrupt enable pin and high priority interrupt enable pin. The change on Port B interrupt will be used as a low priority interrupt since the portion of the TCP/IP stack uses the high priority interrupt when the PIC is operating as a HTTP server. Pull up resistors are also used for the Port B, but only RB5, RB6 and RB7 is declared as input and used to activate to interrupt due to that RB4 is used as the chip select during SD operations and there is also only 3 modules for the moment.
During the first test, it is found that the the interrupt was only able to run once and unable to respond to the next interrupt. After some troubleshooting, it is found that some portion of the emulation code uses a while loop which the code will be stuck there waiting for a response from the SPI or waiting a specific byte to be sent from the SPI and to the PIC. I removed some possible infinite looping code and try to run it without the SPI portion of the codes. It turns out that the PIC was able to react to different interrupts when different pins are connected to ground.
The next thing was to setup the SPI on the RPi and try to do the interrupt together with the SPI. The code will first pull down the pin to activate the module desired and then interact with the PIC through the SPI. To setup the RPI, I used this link to setup the SPI and this link to setup the GPIO. After some minor modification on the Python script, then it is run on the RPi. Six connections are made between the RPi and the PIC, which are three GPIO pins on the RPi will be connected to RB5, RB6 and RB7 and the other 3 pins will be fore the SPI connection between the RPi and the SPI. The connections are RC3 to MCLK, RC4 to MOSI and RC5 to MISO. After some minor corrections, the RPi can activate the ADC module of the slave PIC and get the output from the PIC.