Interrupt is an important element in PIC microcontroller. The interrupt mechanism provides the ability to preempted the processor from running the main program and switch its resources to the peripherals that introduce the interrupt.
The flag is the signature for the microcontroller to identify which peripheral is calling the interrupt. In PIC microcontroller, the name of the flag for each peripheral ended with the word IF. For example: Interrupt flag for Timer 0 ( TMR0IF), Interrupt flag for INT1 (INT1IF) …
The portion of the codes that the processor going to execute during interrupt is called Interrupt Service Routine (ISR). It is the best practice to keep the ISR as short as possible.
It couldn’t be simpler for programming the interrupt using XC8 compiler
Typically, the Resset and Interrupt High and Interrupt Low Vector is located at address, 0×0000, 0×0008, and 0×0018, respectively. However, when a bootloader is burned into the microcontroller, these address spaces have been consumed by the firmware (Microchip USB Bootloader Firmware is located in the memory location from 0×000 till 0x0FFF). Therefore, we have to remapped the memory location manually to acknowledge the microcontroller recognizing the memory layout.
Remapping the memory location is much easier using MPLAB® X and XC8 Compiler.
Goto File > Project Properties
Select the XC8 Linker, then from the choose Additional Options from the drop down menu.
In the CodeOffset Textbox, type 0×1000 (The bootloader is located from 0×0000 till 0x0FFF, therefore our program should start at 0×1000)
Click Apply or OK button to save the configuration.
- Automatically switching the power supply between USB or Battery
- Dual power rating selector: +5v or +3.3v
- 16 Digital I/O (PORTB and PORTD)
- 6 Analog I/O (PORTA)
- 2 PWM (CCP1 and CCP2)
- 1 USART (TX and RX)
A warning is prompted when installing XC8 v1.12 to Windows 7 (64-bit), although the installation was completed after you click the OK button.
According to Microsoft, this has something to do with registering the dll on a 64-bit system (http://support.microsoft.com/kb/282747).
Register is dll manually as suggested by Microsoft.
If you still having problem compiling the code using XC8, try remove and link again the XC8 compiler to MPLAB® X.
- From the MPLAB® X Menu, goto Tools > Options.
- Go to the Embedded Tab in the Options Window, Remove the XC8 (v1.12) from the Toolchain. Then click the Scan for Build Tools button at the bottom.