The PIC18F47Q10 features one 10-bit ADCC module. In this demo, the ADCC peripheral is used to read a value continuously from an analog pin connected to a potentiometer and when a voltage spike is detected, an interrupt that reads the error is triggered.
- TB3263 - Getting Started with ADCC for PIC18
- PIC18F-Q10 Family Product Page
- PIC18F47Q10 Data Sheet
- TB3261 - PIC1000: Getting Started with Writing C-Code for PIC16 and PIC18
- MPLAB® X IDE 5.30 or newer (microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.10 or a newer compiler (microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 3.95.0 or newer (microchip.com/mplab/mplab-code-configurator)
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs (microchip.com/mplab/mplab-code-configurator)
- Microchip PIC18F-Q Series Device Support (1.4.109) or newer (packs.download.microchip.com/)
- PIC18F47Q10 Curiosity Nano (DM182029)
- Curiosity Nano Base for Click boards™ (AC164162)
- POT Click board™ (MIKROE-3402)
The PIC18F47Q10 Curiosity Nano Development Board is used as test platform, along with the Curiosity Nano Base for Click boards™ and the POT Click board™.
The following configurations must be made for this project:
Pin | Configuration |
---|---|
RA0 | Analog Input |
-
Connect the board to the PC.
-
Open the pic18f47q10-cnano-adcc-spike-trigger-mcc.X project in MPLAB® X IDE.
-
Set pic18f47q10-cnano-adcc-spike-trigger-mcc project as main project. Right click on the project in the Projects tab and click Set as Main Project:
-
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:
-
Run the code in debug mode: right click on the project and click Debug:
-
Put a breakpoint inside the ThresholdISR() function by clicking the line number.
-
Turn the potentiometer as quickly as possible. The code will stop at the breakpoint.
-
Add errVal variable to the Variables window: right click on the
errVal
variable in main.c file and click New Watch:
The ADC runs continuously until a sharp increase or decrease is registered. When this happens the interrupt is triggered and the value of the spike can be observed.
This project showcases how the Analog-to-Digital Converter with Computation (ADCC) on the new PIC18-Q10 can be used to monitor a signal for voltage spikes.