Examples

To investigate various kinds of applications and to demonstrate techniques discovered and employed, a collection of examples has been provided:

Common Example Characteristics

Each example provides the following resources:

devconfig.h
device configuration details
Makefile
a build configuration for the example
main.c
the example main program
main.h
definitions for the main program

Device Configuration

The devconfig.h file is intended to provide configuration settings related to the device configuration and oscillator (clock) frequency. The following definitions are employed:

DEVCFG1_CONFIG
the value with which the DEVCFG1 register will be programmed, this typically being constructed using symbols defining values for various register fields
DEVCFG2_CONFIG
the value with which the DEVCFG2 register will be programmed
FPB
the peripheral clock frequency, whose value will be a consequence of the above register settings

Build Configuration

The Makefile is concerned with defining source and program (target) files, build artefacts, configuration flags, employing the common definitions and rules found in the mk directory located at the top level of the CommonPIC32 distribution.

Main Program

The main.c and main.h files are concerned with providing a main function with the following signature:

void main(void);

Since the mk/common.mk definitions file used by the build configuration provides access to various library files, the first tasks performed by the main function are likely to involve initialisation using various init_-prefixed functions.

Other necessary functions are those handling exceptions and interrupts, having the following signatures:

void exception_handler(void);
void interrupt_handler(void);

These functions are called by the low-level library functionality when CPU exceptions and interrupts occur.