8 Using TMR2 for Auto-Conversion Trigger for the ADCC Module
This example will present how to use the TMR2 peripheral to trigger the ADCC to make conversions at a fixed frequency rate that can be adjusted by modifying the TMR2 period.
The application will blink the LED0 with a rate of Timer2 period (100 ms), get the ADCC value and compare it with a desired threshold and, if it is higher, the LED0 will stop blinking.
This example uses the PIC18F47Q10 Curiosity Nano board with a POT click, both inserted into a Curiosity Nano adapter. For more details, visit the Hardware Configuration section in the GitHub repository.
- System clock initialization
- ADCC initialization and reading
- Port initialization
- Timer2 initialization
- Interrupts handling and initialization