AN2039-Adding a Timer

Using MPLAB® Code Configurator (MCC) to add Timer1 function to an application

With the project opened in MPLAB X, from the main menu, select Tools > Microchip Embedded > MPLAB Code Configurator.

pic1.png

After MCC opens, from the Device Resources menu, select Timer1 to bring it into the Project Resources window:

pic2.png

Click on TMR1 to edit and enter values to configure TMR1:

pic3.png

To configure the TMR1 for a 1-millisecond (mS) interrupt using the 16 MHz internal clock, edit the Time Period to 1.0 mS, check the Enable Timer Interrupt box, and edit the Callback Function Rate to 1.

pic4.png

Click the Generate Code button for MCC to create code for TMR1.

pic5.png

Using the MCC, this method can be used to initialize and create functions for the Analog-to-Digital Converter (ADC), Pulse Width Modulation (PWM), GPIO, Flash Memory, and I²C.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.