This project is a general template file for the PIC12 Family of
microcontrollers.  It's purpose is to provide a project shell for users to
get started designing their own applications.  Final qualification and testing
of this project is left to the user.

ADVANCED USER TIP

From the main menu, refer to the Task list by going to Window > Tasks (Ctrl+6).
As long as the task window is not configured to filter out any tasks,
the getting started TODO list embedded in this project will be displayed.

Make sure the 'Show tasks for the main project and for the open projects which
depend on it' option is selected on the left hand side of the Tasks window so
that tasks related to other projects are not active.

HOW TO ADD YOUR OWN CODE TO A TEMPLATE

STEP 1

First install the appropriate C compiler if you have not done so already.

See www.microchip.com/compilers

Next, build this project by clicking the Clean and Build Icon (the hammer and
broom symbol) in the MPLAB X IDE Toolbar.  If this project builds, then you are
ready to make changes for your own application.  If the project does not build,
you need to troubleshoot why the project does not build before moving on.

STEP 2

Embed your device's configuration bits into the code.  Instructions for this
are commented in configuration_bits.c

STEP 3

Unless interrupts are not used in your application, fill in the interrupt
vector code.  Code stubs are provided in interrupts.c.  Check the device
datasheet to confirm that you are servicing all the relevant enabled
interrupts in your application within the ISR.  Note that it is important
to check interrupt flags in sequence within one conditional statement to
avoid interrupt contention which could result in corrupting the interrupt
context.

STEP 4

Define system parameters such as the system operating frequency in system.h.

If your device stores an oscillator calibration value at the end of program
memory, incorporate the _READ_OSCCAL_DATA() function in system.c.  The device
datasheet will tell you if calibration data is stored at the end of the
device memory.

Add system level functions to system.h and system.c.  For example, if
you want a function to determine the reset source of the device to know if you
need to backup data, do an oscillator switch, enter a low power mode, etc...
these types of functions may be added to system.c and prototypes can go in
system.h.

STEP 5

Add user level functions to user.h and user.c.  User level functions are
functions that initialize I/O, initialize user peripherals like the ADC,
compute user algorithms, perform calculations on sampled user data, and so on.
User function prototypes and macros may be placed in user.h, and user
functions themselves may go in user.c

STEP 6

Add code to main.c on the line that says <INSERT USER APPLICATION CODE HERE>.
For example, here you would call functions in user.c or system.c, or possibly
setup your own state machine or primary code loop.

Global variables may be added to main.c as well.  As a general practice, macros
and prototypes may go in header files, but variable declarations should not
go in .h files.  Variable declarations should be placed in .c files.

STEP 7

Design the rest of your application.  Add new files to the application, and
test the finished product.

STEP 8

Document what the project does and include other project information in
project_information.txt.

