Digilent MX4cK User Manual

Page 10

Advertising
background image

Cerebot MX4cK Reference Manual

www.digilentinc.com

page 10 of 35

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




When using the Cerebot MX4cK with the
chipKIT MPIDE the functions pinMode(),
digitalRead(), and digitalWrite() are used for
digital pin I/O.

The pinMode() function is used to set the pin
direction. Pin direction can be set to: INPUT,
OUTPUT, or OPEN. OPEN is used for open-
drain and implies output.

The digitalRead() and digitalWrite() functions
are used to read or write the pins.
DigitalRead() returns the current state of the
specified pin, and digitalWrite is used to set the
state of an output pin. The pin state can be
either HIGH or LOW.

PIC32MX460 Pin 20


Pin 20 on the PIC32MX460 has multiple
functions. It provides the VBUSON signal when
the board is being used to implement a USB
host. It also provides the positive input for
analog comparator 1, analog to digital
converter input AN5, change notice interrupt
CN7 and bit 5 of general I/O Port B. In order to
support all of these different functions, jumper
block J16 is used to select the routing of this
pin.

Normally, the shorting block will be in the JJ-8
position. This connects microcontroller pin 20
to Pmod connector JJ pin 8. This allows the
use of most functions of this pin.

When the board is being used as a USB host,
the shorting block is placed in the VBUSON
position to allow use of the VBUSON signal to
control power to the USB bus.

Placing the shorting block in the DAC position
connects the output of IC3, the MCP4725
digital to analog converter to microcontroller
pin 20. This allows use of the DAC output to be
used as a programmable reference for analog
comparator 1.

Push Buttons and LEDs


The Cerebot MX4cK board provides two push
button switches for user input and four LEDs
for output. The buttons, BTN1 and BTN2 are
connected to I/O pins TRCLK/RA6 and
TRD3/RA7 respectively. To read the buttons,
pins 6 and 7 of I/O Port A must be set as
inputs by setting the corresponding bits in the
TRISA register. The button state is then
obtained by reading the PORTA register.
When a button is pressed, the corresponding
bit will be high (‘1’). Note that the
microcontroller pins used by the buttons are
shared with pins 3 & 4 of Pmod connector JF.

The four LEDs are connected to bits 10-13 of
I/O Port B. LED 1 is connected to bit 10, LED 2
is connected to bit 11, and so on. These four
bits are also shared with pins 1-4 of Pmod
connector JK. To use the LEDs, set the
desired bits as outputs by clearing the
corresponding bits in the TRISB register. The
state of an LED is set by writing values to the
LATB register. Setting a bit to 1 will illuminate
the LED and setting the bit to 0 will turn it off.

When using the MPIDE and the chipKIT
system, the buttons are accessed using
digitalRead() and the LEDs using digitalWrite().
Use the following pins to access them:

• BTN1 – PIN_BTN1, pin 42, RA6
• BTN2 – PIN_BTN2, pin 43, RA7
• LD1 – PIN_LED1, pin 64, RB10
• LD2 – PIN_LED2, pin 65, RB11
• LD3 – PIN_LED3, pin 66, RB12
• LD4 – PIN_LED4, pin 67, RB13

RC Servo Connectors


The Cerebot MX4cK provides eight 3-pin RC
hobby servo connectors, labeled S1-S8, for
direct control of servos in robotics and
embedded hardware actuator applications.
The connectors share the I/O pins with Pmod
connector JC. Individual I/O pins may be

Advertising