The 'pic16f15244-led-timer-example' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to toggle LED0 every second using Timer1 to configure that one second period.
- MPLAB® X IDE 6.10 or newer (microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.41 or a newer compiler (microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 5.3.7 or newer (microchip.com/mplab/mplab-code-configurator)
- Microchip PIC16F1xxxx Series Device Support (1.18.352) or newer (packs.download.microchip.com/)
- PIC16F15244 Curiosity Nano (EV09Z19A)
- Micro-USB to USB 2.0 cable
- Connect the PIC16f15244 Curiosity Nano board to a PC using the Micro-USB to USB 2.0 cable.
- Download and install MPLAB®X IDE version 6.10, or newer.
- Download and install the XC8 C-Compiler version 2.41, or newer.
- Open the 'pic16f15244-led-timer-example.X' project, as shown in Figure 1.
- Press Open Project to open the Project Properties window. Select the Curiosity tool from the tools drop-down menu, as shown in Figure 2.
- Press Make and Program Device to program the PIC, as shown in Figure 3. Verify if the device was successfully programmed, as shown in Figure 4.
After the Curiosity Nano is programmed, LED0 states will switch from 'ON' to 'OFF' every second.
Timer1 is configured such that it will roll-over every second, causing an interrupt event to occur. Timer1 can be quickly configured using MCC. Figure 5 shows the configuration used to generate an interrupt once every second. During the Timer1 Interrupt Service Routine (ISR), pin RA2 is toggled, which allows LED0 to change states.
static void Timer1_DefaultOverflowCallback(void)
{
if(LED0_TRIS == 1)
{
LED0_SetDigitalOutput();
}
else
{
LED0_SetDigitalInput();
}
}
The 'pic16f15244-led-timer-example' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to toggle LED0 every second using Timer1 to configure that one second period.