Skip to content

This repository provides an example of MCC-generated code for using GPIO Interrupts and shows how to enable the Interrupt-on-Change (IOC). The IOC is configured to be triggered on the falling edge detected on the desired input pin.

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f47q10-cnano-gpio-int-mcc

Repository files navigation

MCHP

PIC18F47Q10 GPIO Interrupt

Objective

The PIC18F47Q10 provides multiple PORT modules.

In this example, the interrupt is configured to be triggered on the falling edge of the input signal (the value is changed from logic ‘1’ to logic ‘0’), in order to generate the interrupt when the button is pressed. The interrupt routine consists in toggling the output pin value, causing the LED to turn on and off.

For this example, the RA0 pin is configured as input with IOC enabled on falling edge and connected to a button, and the RE0 pin is configured as output and connected to an LED.

Related Documentation

Software Used

Hardware Used

Setup

The PIC18F47Q10 Curiosity Nano Development Board is used as the test platform.


The following configurations must be made for this project:

  • Clock:
    • Oscillator Select: HFINTOSC
    • HF Internal Clock: Select 1_MHz
    • Clock Divider: 1
  • Watchdog Timer: disabled
  • Low-voltage Programming: enabled
Pin Configuration
RA0 Digital Input
RE0 (LED0) Output

The RA0 will be connected to the user button using a wire.

Operation

  1. Connect the board to the PC.

  2. Open the pic18f47q10-cnano-gpio-int-mcc.X project in MPLAB® X IDE.

  3. Set pic18f47q10-cnano-gpio-int-mcc.X project as main project. Right click on the project in the Projects tab and click Set as Main Project:


  1. Select the PIC18F47Q10 Curiosity Nano in the Hardware Tool section of the project settings:
  • Right click on the project and click Properties;
  • Select the PIC18F47Q10 Curiosity Nano (click on the SN) in the Hardware Tool tab and then click OK:


  1. Program the project to the board: right click on the project and click Make and Program Device:


Result:

Demo

Summary

This project showcases how the General Purpose Input/Output pins on the PIC18F47Q10 can be used as inputs and outputs in order to receive an Interrupt-on-Change and drive an LED high or low.

About

This repository provides an example of MCC-generated code for using GPIO Interrupts and shows how to enable the Interrupt-on-Change (IOC). The IOC is configured to be triggered on the falling edge detected on the desired input pin.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published