Digilent MX3cK User Manual

Page 14

Advertising
background image

Cerebot MX3cK Reference Manual

www.digilentinc.com

page 14 of 23

Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.


The analog reference input pins are shared
with two of the analog inputs. Vref- is shared
with A3 (AN1/RB1), and Vref+ is shared with
A2 (AN0/RB0). These pins are not available to
be used as analog inputs when being used as
an external reference.

When using the chipKIT MPIDE software, the
use of external analog references is selected
using the analogReference() function. The
following values can be used with
analogReference():

• DEFAULT – Vref- = 0V, Vref+ = 3.3V
• INTERNAL – same as default
• EXTERNAL – Vref- = 0V, Vref+ = voltage

at A2

• EXTMINUS – Vref- = voltage at A3, Vref+ =

3.3V

• EXTPLUSMINUS – Vref- = voltage at A3,

Vref+ = voltage at A2

Timers


The PIC32 microcontroller provides five timers
that can be used for various timing functions.
These timers are each 16 bits wide, although
two pairs, TIMER2/TIMER3 and
TIMER4/TIMER5 can be combined to produce
32 bit wide timers.

A timer consists of a control register, a counter
register, and a period register. The control
register is used to configure the timer for
various modes of operation. The count register
counts cycles of the clock source selected via
the control register. This clock source can be
the peripheral bus clock or a division of the
peripheral bus clock via a pre-scaler divider.
The period register can be used to generate an
interrupt and/or reset the count register when a
pre-determined value is reached.

For detailed information on the operation of the
PIC32 timers, refer to the PIC32 Family
Reference Manual, Section 14, Timers.

Control and operation of the timers is not
explicitly provided in the current version of the

chipKIT MPIDE software. This capability will be
added in a future version of the software.
Timers are used implicitly by various core
functions and libraries, however.

Output Compare


The PIC32 microcontroller provides five output
compare units that can be used to control the
timing of state changes on certain output pins
or to generate pulse width modulated (PWM)
outputs.


Each output compare unit works with a
particular output pin (OC1-OC5). It can be
programmed to control the pin in any of the
following ways:

• PWM output
• Generate continuous pulses
• Generate a single pulse
• Toggle the output pin
• Generate falling edge
• Generate rising edge


The output compare units work in conjunction
with a timer. Either Timer2 or Timer3 can be
used with any of the five output compare units.

Refer to the PIC32 Family Reference Manual,
Section 16, Output Compare for detailed
information on the use of the output compares
units.

When using the chipKIT MPIDE software,
these are accessed using the analogWrite()
function. The digital pin number, or preferably,
the symbols PIN_OC1 through PIN_OC5 are
used to specify the pin. The chipKIT MPIDE
software currently only supports using the
output compare units to generate PWM
outputs. It uses Timer2 to control the output
compares.

The following gives Pmod connector position,
chipKIT pin number, and microcontroller I/O
port and bit number for the output compare
unit’s output pins:

Advertising