Digilent ChipKIT PRO Reference Manual

1300 Henley Court
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of their respective owners.
Pullman, WA 99163
509.334.6306
www.digilentinc.com
ChipKIT™ PRO MX4 Board Reference Manual
Table of Contents
Table of Contents .................................................................................................................. 1
Overview ............................................................................................................................... 3
1 Functional Description ................................................................................................... 4
2 Programming Tools ............................................................................................................. 4
2.1 Using ChipKIT Pro MX4 with Microchip Development Tools ................................................ 5
2.3 Additional Tools Information ................................................................................................ 7
3 Power Supply ..................................................................................................................... 7
3.1 Power Supply Monitor Circuit ............................................................................................... 9
4 Pmod Connectors ............................................................................................................... 9
5 Digital I/O ......................................................................................................................... 10
5.1 PIC32MX460 Pin 20 ............................................................................................................. 11
5.2 Push Buttons and LEDs ....................................................................................................... 11
5.3 RC Servo Connectors ........................................................................................................... 12
6 5V Signal Compatibility ..................................................................................................... 13
7 CPU Clock Source .............................................................................................................. 14
8 USB Interface .................................................................................................................... 15
9 UART Interface ................................................................................................................. 16
DOC#: 502-295
Page 1 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
10 Serial Peripheral Interface (SPI) ....................................................................................... 17
11 I2C ™ Interface ................................................................................................................ 18
11.1 Jumper Setting for I2C Pull Up Resistors ........................................................................... 19
11.2 On-Board I2C Peripheral Devices ...................................................................................... 20
12 Analog Inputs ................................................................................................................. 20
13 A/D Converter Voltage Reference ................................................................................... 21
14 Timers ............................................................................................................................ 21
15 Output Compare ............................................................................................................. 22
16 Input Capture ................................................................................................................. 22
17 External Interrupts .......................................................................................................... 23
18 RTCC ............................................................................................................................... 23
Appendix A: Connector Descriptions and Jumper Settings .................................................... 25
Appendix B: Example of Configuration Values ...................................................................... 28
Appendix C: Connector Pinout Tables .................................................................................. 29
Arranged by Microcontroller Pin Number ............................................................................ 29
Arranged by Connector Pin Number and Digital Pin Number .............................................. 32
Arranged by Microcontroller I/O Port Name and Bit Number ............................................. 35
Page 2 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
Overview
ChipKIT Pro MX4 is the new name for Cerebot MX4ck. This board retains all functionality of the Cerebot MX4ck.
The ChipKIT Pro MX4 is a microcontroller development board based on the Microchip PIC32MX460F512L, a member of the 32-bit PIC32 microcontroller family. It is compatible with Digilent’s line of Pmod™ peripheral modules, and is suitable for use with the Microchip MPLAB® IDE tools. The ChipKIT Pro MX4 is also compatible for use with the MPIDE development environment. ChipKIT combined with MPIDE is a PIC32 based system compatible with many existing Arduino™ code examples, reference materials and other resources.
Features of the ChipKIT Pro MX4 Include:
a PIC32MX460F512L microcontroller
support for programming and debugging within
the Microchip MPLAB development environment
support for programming within the chipKIT MPIDE development environment
nine Pmod connectors for Digilent peripheral module boards
eight hobby RC servo connectors
USB 2.0 Device, Host, and OTG support
two push buttons
four LEDs
multiple power supply options, including USB
powered
ESD protection and short circuit protection for all I/O pins.
Features of the PIC32MX460F512L Include
512KB internal program flash memory
32KB internal SRAM memory
USB 2.0 compliant full-speed On-The-Go (OTG)
ChipKIT Pro MX4]
controller with dedicated DMA channel
two serial peripheral interfaces (SPI)
two UART serial interfaces
two I2C serial interfaces
five 16-bit timer/counters
five timer capture inputs
five compare/PWM outputs
sixteen 10-bit analog inputs
two analog comparators
Page 3 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
ChipKIT Pro MX4 Circuit Diagram
The ChipKIT Pro MX4 is designed to be easy to use and suitable for use by anyone from beginners to advanced users for experimenting with electronics and embedded control systems. A built in programming/debugging circuit compatible with the Microchip MPLAB® IDE is provided on the board, so no additional hardware is required for use with MPLAB. The kit contains everything needed to start developing embedded applications using either the MPLAB® IDE or the MPIDE.
The ChipKIT Pro MX4 provides 74 I/O pins that support a number of peripheral functions, such as USB controller, UART, SPI and I2C™ ports as well as five pulse width modulated outputs and five external interrupt inputs. Fifteen of the I/O pins can be used as analog inputs in addition to their use as digital inputs and outputs.
The ChipKIT Pro MX4 can be powered via USB, or an external power supply that may be either an AC-DC power adapter, or batteries.
1 Functional Description
The ChipKIT Pro MX4 is designed for embedded control and robotics control applications as well as for general microprocessor experimentation. Firmware suitable for many applications can be downloaded to the ChipKIT Pro MX4’s programmable PIC32 microcontroller
The ChipKIT Pro MX4 has a number of input/output connection options, and is specially designed to work with the Digilent Pmod™ line of peripheral modules to provide a variety of input and output functions. For more information, see www.digilentinc.com. In addition to the Pmod connectors, the board provides eight connectors for RC hobby servos, two push button switches, and four LEDs, as well as providing connections for two I2C busses. A serial EEPROM and a 12-bit digital to analog converter are provided on one of the I2C busses.
The ChipKIT Pro MX4 features a flexible power supply system with a number of options for powering the board as well as powering peripheral devices connected to the board. It can be USB powered via the USB serial converter port, the debug USB port or the USB device port. It also can be powered from an external power supply or batteries.
2 Programming Tools
The ChipKIT Pro MX4 can be used with either the Microchip MPLAB® development environment or the MPIDE development environment. When used with the MPLAB® IDE, in-system-programming and debugging of firmware
Page 4 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
running on the PIC32MX460 microcontroller is supported using an on-board programming/debugging circuit licensed from Microchip.
The ChipKIT Pro MX4 is immediately useable with either the MPLAB IDE or the MPIDE. No additional hardware is required to use the board with the Microchip MPLAB tools.
2.1 Using ChipKIT Pro MX4 with Microchip Development Tools
The Microchip MPLAB® IDE or the MPLAB® X IDE can be used to program and debug code running on the ChipKIT Pro MX4 board using the built-in programming/debugging circuit licensed from Microchip.
The MPLAB development environment can be downloaded from the Microchip web site. This software suite includes a free evaluation copy of the Microchip C32 compiler for use with the PIC32 microcontroller family. The licensed debugger is compatible with the MPLAB IDE version 8.63 or later.
When creating a new project, use the “Configure.Select Device…” menu to specify the PIC32 device being used. Ensure that the device is set to PIC32MX460F512L.
In order to use the on-board program/debug circuit it must be selected as the debugger or programmer within the MPLAB IDE. Use the “Debugger.Select Tool” menu, or the “Programmer.Select Tool” menu, and select “Licensed Debugger” as the programmer or debugger.
The licensed debugger interface uses USB connector J9, labeled DEBUG. Connector J9 is a USB micro-B connector, located next to the power switch. Use a USB-A to micro-B cable (provided with the board) to connect to an available USB port on the PC.
When the licensed debugger is selected as the programming or debugging device, the MPLAB IDE will check the version number of the firmware running on the debugger and offer to update it if is out of date with the version of MPLAB being used.
The in-system programming/debugging interface uses two pins on the PIC32 microcontroller. The PIC32 devices support two alternate pin pairs for this interface: PGC1/PGD1 or PGC2/PGD2. PIC32 devices use PGC2/PGD2 by default. The ChipKIT Pro MX4 is designed to use PGC2/PGD2. It is not normally necessary to select the use of PGC2/PGD2 for the debugging interface, as this should occur automatically.
If for some reason, it is necessary to select the correct pins for the programming/debugging interface, this can done using configuration variables set using the #pragma config statement. The following statement can be used to configure the microcontroller for use with the on-board licensed debugger circuit:
#pragma config ICESEL = ICS_PGx2
The MPLAB IDE may report an error indicating that the device is not configured for debugging until the first time a program is loaded onto the board, or a program that is configured to use PGC1/PGD1 has been programmed.
The MCLR pin on the PIC32 microcontroller is used by the hardware programming/debugging interface to reset the processor. This same pin is used by the USB serial converter to reset the processor when using the MPIDE. It is possible that the reset function from the USB serial interface can interfere with correct operation of the Microchip programming and debugging tools. If this happens, jumper JP8 can be used to disconnect the USB serial converter reset circuit. Remove the shorting block from JP8 to disable the reset circuit. If the shorting block has been removed, it is necessary to reinstall it on JP8 in order to use the ChipKIT Pro MX4 board with the MPIDE again.
Using the Microchip development tools to program the ChipKIT Pro MX4 will erase the chipKIT boot loader. To use the board with the MPIDE again, it is necessary to program the boot loader back onto the board. The programming
Page 5 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
file for the boot loader that was programmed into the board by Digilent at the factory is available for download from the ChipKIT Pro MX4 product page on the Digilent web site. Additionally, the boot loader source code is available in the chipKIT project repository at www.github.com/chipKIT32/pic32-Arduino-Bootloader.
To reprogram the boot loader using MPLAB, perform the following steps:
Use the “Configure.Select Device …” menu to select the PIC32MX460F512L
Use the “Programmer.Select Programmer” menu to select the “Licensed Debugger”.
Use the “File Import…” dialog box to navigate to and select the boot loader programming downloaded from
the Digilent web site. The file name will be something like: chipKIT_Bootloader_MX4.hex
Use the “Programmer.Program” command to program all memories on the device.
2.2 Using ChipKIT Pro MX4 with MPIDE ChipKIT and the MPIDE is a PIC32 based hardware and software system compatible with many existing Arduino™ code examples, reference materials and other resources. The MPIDE development platform was produced by modifying the Arduino™ IDE and is fully backward compatible with the Arduino IDE. The ChipKIT Pro MX4 board is designed to be fully compatible with the MPIDE system, version 20111221 or later.
The MPIDE uses a serial communications port to communicate with a boot loader running in the target board. The serial port on the MX4 board is implemented using an FTDI FT232R USB serial converter. Before attempting to use the MPIDE to communicate with the MX4, the appropriate USB device driver must be installed.
The USB serial converter on the ChipKIT Pro MX4 board uses USB connector J8, labeled UART on the board. This connector is a micro-USB located next to screw terminal connector J5. Use a standard USB-A to mini-B cable (provided with the board) to connect the board to an available USB port on the PC.
In the MPIDE, use the “Tools.Board” command to select the ChipKIT Pro MX4 from the list of available boards. Use the “Tools.Serial Port” command to choose the appropriate serial port from the list of available serial ports on the PC.
When the MPIDE needs to communicate with the MX4 board, the PIC32 microcontroller is reset and starts running the boot loader. The MPIDE then establishes communications with the boot loader and downloads the program to the board.
When the MPIDE opens the serial communications connection on the PC, the DTR pin on the FT232R chip is driven low. This pin is coupled through a capacitor to the MCLR pin on the PIC32 microcontroller. Driving the MCLR line low resets the microcontroller, restarting execution with the boot loader.
Once the MPIDE has established communication with the boot loader, it transfers the user’s program to the boot loader, which programs it into the flash memory in the Microcontroller.
The automatic reset action when the serial communications connection is opened can be disabled. To disable this operation, remove the shorting block from jumper JP8. The shorting block is reinstalled on JP8 to restore operation with the MPIDE.
Two red LEDs (LD7 and LD8) will blink when data is being sent or received between the ChipKIT Pro MX4 and the PC over the serial connection.
The header connector J7 provides access to the other serial handshaking signals provided by the FT232R. Connector J7 is not loaded at the factory but can be installed by the user to access these signals.
Page 6 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
2.3 Additional Tools Information
For additional information about the ChipKIT Pro MX4 board and the use and operation of the PIC32MX460F512L microcontroller, refer to the following documents in addition to this reference manual.
The ChipKIT Pro MX4 Schematic, available on the ChipKIT Pro MX4 product page on the Digilent web site:
www.digilentinc.com
The PIC32MX3XX/4XX Family Data Sheet and the PIC32MX Family Reference Manual available from the Microchip web site: www.microchip.com
Additional reference material for the MPIDE system is included in the MPIDE software download, and on-line in the chipKIT wiki. Help with questions and problems using the board with the MPIDE software can also be obtained in the chipKIT forums:
www.chipKIT.net/install (software download)
www.chipKIT.net
www.chipKIT.org/forum
3 Power Supply
Switch SW1, on the left side of the board is the power switch. Place this switch in the ON position to turn on board power and in the OFF position to turn off board power.
The ChipKIT Pro MX4 may be USB powered via either the USB debug port, the USB UART port, or the USB device port. Alternatively, the board may be powered via dedicated, “external”, power supply connectors.
Jumper block J12 is used to select the power source used to provide power to the board. This jumper block provides the following four positions:
USB – power is supplied by USB device connector J15. This is used when the ChipKIT Pro MX4 is used to implement a USB bus powered device.
EXT – Power is supplied by one of the external power connectors.
DBG – Power is supplied by DEBUG USB connector J9.
URT – Power is supplied by UART USB connector J8.
Place the shorting block in the appropriate position on J12 for the desired power source for the board.
The ChipKIT Pro MX4 is rated for external power from 3.6 to 12 volts DC. Using a voltage outside this range could damage the board and connected devices. If operating the board at a voltage greater than 5V, it is necessary to remove the shorting block on jumper JP10 to protect the USB load switch, which is limited to a maximum voltage of 5.5V. The USB load switch is used to control bus power when the ChipKIT Pro MX4 is being used to implement a USB host. When operating from any of the three USB sources, the input voltage will be 5V.
The output of power select jumper block J12 is connected to the VIN power bus. The VIN power bus supplies power to Q3, a PFET load switch, and IC9, the voltage regulator for the licensed debugger circuit. The licensed debugger circuit is powered as soon as the power switch is turned on. Power to the rest of the board is controlled by Q3. The main board power supply is enabled by bringing the gate of Q3 low. When Q3 is turned on, the unregulated power bus BRD_VU is powered.
Page 7 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
If the licensed debugger is connected to an active USB port, it enumerates with the host computer and once it has been successfully enumerated, it turns on the main board power supply by driving the PWR_ON signal high.
If the licensed debugger is not connected to an active USB port, the PWR_ON signal is ignored and board power is turned on immediately by the power switch via transistor Q4.
The main board power supply is a switch mode voltage regulator implemented using a Microchip MCP16301 switch mode step-down regulator. This regulator provides 3.3V at up to 600 mA with approximately 96% efficiency. This powers the main board regulated power bus BRD_3V3
There are three connectors on ChipKIT Pro MX4 for connecting an external power supply: J13, J14, and J18.
The barrel connector, J13, is useful for desktop development and testing where using USB or battery power is not suitable. J13 is the connector used by the AC adapter optionally available from Digilent, or other sources. J13 is a
2.5mm x 5.5mm coaxial connector wired with the center terminal as the positive voltage.
Connector J14 is a two-pin male header that provides easy battery or battery-pack connection. Digilent has both two-cell and four-cell AA battery holders with two pin connectors available for connection to J14.
Connector J18 is a screw terminal connector for an alternative power supply connection for use with higher current battery packs, bench supplies or other power sources where use of a hard wired power supply is desirable.
Connectors J13, J14, and J18 are wired in parallel and connect to the “External Power” position on the Power Select jumper block J12. A shorting block should be placed on the “EXT” position of J12 when using this option for board power. Only one of these three power connectors should be used at a time. If multiple power supplies are connected simultaneously, damage to the board or the power supplies may occur.
When using an external power supply, ensure that the polarity is not reversed as the board is not protected from reverse polarity on the power supply and will be damaged.
The ChipKIT Pro MX4 has a second screw terminal connector, J5 that supplies power to the servo power bus, VS, to power the RC hobby servo connectors. This allows servos to be powered from a separate power supply than the one powering the electronics on the ChipKIT Pro MX4. This can be useful when using servos that draw large amounts of power.
Jumper JP1 can be used to connect the ChipKIT Pro MX4 unregulated power bus BRD_VU to the servo power bus, VS. When no shorting block is installed on JP1, the BRD_VU and VS busses are separate. When a shorting block is on JP1, the two busses are joined and the BRD_VU bus can be powered in any of the previously indicated ways, or from connector J5.
The ChipKIT Pro MX4 can provide power to any peripheral modules attached to the Pmod connectors and to I2C devices powered from the I2C daisy chain connectors, J2 and J6. Each Pmod connector provides power pins that can be powered by either unregulated voltage, BRD_VU, or regulated voltage, BRD_3V3, by setting the voltage jumper block to the desired position. The I2C power connectors only provide regulated voltage, BRD_3V3.
The PIC32 microcontroller and on-board I/O devices operate at a supply voltage of 3.3V provided by the BRD_3V3 bus. The PIC32 microcontroller will use approximately 55mA when running at 80MHz. The other circuitry on the board will use approximately 10mA. The remaining current is available to provide power to attached Pmod and I2C devices.
Page 8 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
3.1 Power Supply Monitor Circuit
The ChipKIT Pro MX4 microcontroller can measure the power supply voltage on the BRD_VU and VS power busses using the provided power supply monitor circuits. This feature is especially useful when using batteries because it allows the microcontroller firmware to determine the charge state of the battery and potentially notify the user when a battery supply is low.
Each power supply monitor circuit is made up of a voltage divider that divides the power bus voltage by four, and a filter capacitor to stabilize the voltage. Jumper JP4 enables the supply monitor circuit for BRD_VU power bus, and jumper JP2 enables the supply monitor circuit for the VS power bus. The analog to digital converter built into the PIC32 microcontroller is used to measure the power supply voltages. ADC channel 8 is used to measure BRD_VU and ADC channel 9 is used to measure VS.
When using the ChipKIT Pro MX4 with the MPIDE, these are accessed using the analogRead() function using analog input A6 to read BRD_VU and A7 to read VS.
4 Pmod Connectors
The ChipKIT Pro MX4 has nine connectors for connecting Digilent Pmod peripheral modules. The Pmod connectors, labeled JA–JF and JH–JK, are 2x8 pin right-angle, female pin header connectors. Each connector has an associated power select jumper block labeled JPA–JPF and JPH–JPK.
Digilent Pmods are a line of small peripheral modules that provide various kinds of I/O interfaces. The Pmod product line includes such things as button, switch and LED modules, connector modules, LCD displays, high current output drivers, various kinds of RF interfaces, and many others.
There are two styles of Pmod connector: six-pin and twelve-pin. Both connectors use standard pin headers with 100mil spaced pins. The six-pin connectors have the pins in a 1x6 configuration, while the twelve-pin connectors use a 2x6 configuration. All of the Pmod connectors on the ChipKIT Pro MX4 are twelve pin connectors.
Six-pin Pmod connectors provide four I/O signals, ground and a switchable power connection. The twelve-pin connectors provide eight I/O signals, two power and two ground pins. The twelve-pin connectors have the signals arranged so that one twelve-pin connector is equivalent to two of the six-pin connectors. Pins 1–4 and 7–10 are the signal pins, pins 5 and 11 are the ground pins and pins 6 & 12 are the power supply pins.
The pin numbering that Digilent uses on the twelve-pin Pmod connectors is non-standard. The upper row of pins are numbered 1–6, left to right (when viewed from the top of the board), and the lower row of pins are numbered 7–12, left to right. This is in keeping with the convention that the upper and lower rows of pins can be considered to be two six-pin connectors stacked. When viewed from the end of the connector, pin 1 is the upper right pin and pin 7 is immediately below it (closer to the PCB).
Each Pmod connector has an associated power select jumper. These are used to select the power supply voltage supplied to the power supply pin on the Pmod connector. They are switchable between either the unregulated power supply, BRD_VU, or the 3.3V main board supply, BRD_3V3. Place the shorting block in the 3V3 position for regulated 3.3V and in the VU position to use the unregulated supply.
Each signal pin on the Pmod connectors is connected to an input/output pin on the PIC32 microcontroller. Each pin has a 200 ohm series resistor and an ESD protection diode. The series resistor provides short circuit protection to prevent damaging the I/O block in the microcontroller if the pin is inadvertently shorted to VDD or GND, or two outputs are shorted together. The ESD protection diode protects the I/O block from damage due to electro-static discharge.
Page 9 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
Although ESD protection is provided between the connector pins and the microcontroller pins, ESD safe handling procedures should be followed when handling the circuit board. The pins on the microcontroller and other circuits on the board are exposed and can be damaged through ESD when handling the board.
Digilent Pmod peripheral modules can either be plugged directly into the connectors on the ChipKIT Pro MX4 or attached via cables. Digilent has a variety of Pmod interconnect cables available.
See the Pinout Tables in Appendix C, for more information about connecting peripheral modules and other devices to the ChipKIT Pro MX4. These tables describe the mapping between pins on the PIC32MX460 microcontroller and the pins on the various connectors.
The PIC32 microcontroller can source or sink a maximum of 18mA on all digital I/O pins. However, to keep the output voltage within the specified input/output voltage range (VOL 0.4V, VOH 2.4V) the pin current must be restricted to +7/-12mA. The maximum current that can be sourced or sunk across all I/O pins simultaneously is +/­200mA. The maximum voltage that can be applied to any digital only I/O pin is 5.5V. The maximum voltage that can be applied to any analog capable I/O pin is 3.6V. For more detailed specifications, refer to the PIC32MX3XX/4XX Family Data Sheet.
5 Digital I/O
The ChipKIT Pro MX4 board provides access to 72 of the I/O pins from the PIC32 microcontroller via the Pmod connectors. Two additional I/O pins can be accessed via the I2C connector, J6. Any of the pins on the Pmod or I2C connectors can be individually accessed for digital input or output. Note that when the I2C signals on J6 are being used for I2C communications, they are not available for general purpose I/O. Note that the signals on I2C connector J2 are shared with pins 1 & 2 of Pmod connector JF. On PIC32 microcontrollers, the input/output pins are grouped into I/O Ports and are accessed via peripheral registers in the microcontroller. There are seven I/O Ports numbered A–G and each is 16 bits wide. Depending on the particular PIC32 microcontroller, some of the I/O Ports are not present, and not all 16 bits are present in all I/O Ports.
Each I/O Port has four control registers: TRIS, LAT, PORT, and ODC. The registers for I/O Port A are named TRISA, LATA, PORTA and ODCA. The registers for the other I/O Ports are named similarly.
The TRIS register is used to set the pin direction. Setting a TRIS bit to 0 makes the pin an output. Setting the TRIS bit to 1 makes the pin an input.
The LAT register is used to write to the I/O Port. Writing to the LAT register sets the output level of any pins configured as outputs. Reading from the LAT register returns the last value written.
The PORT register is used to read from the I/O Port. Reading from the PORT register returns the current state of all of the pins in the I/O Port. Writing to the PORT register is equivalent to writing to the LAT register.
PIC32 microcontrollers allow any pin set as an output to be configured as either a normal totem-pole output or as an open-drain output. The ODC register is used to control the output type. Setting an ODC bit to 0 makes the pin a normal output and setting it to 1 makes the pin an open drain output.
Refer to the PIC32MX3XX/4XX Family Data Sheet, and the PIC32 Family Reference Manual, Section 12, IO Ports, for more detailed information about the operation of the I/O Ports in the microcontroller.
The MPIDE system uses logical pin numbers to identify digital I/O pins on the connectors. These pin numbers start with pin 0 and are numbered up consecutively.
Page 10 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
On the ChipKIT Pro MX4, pin numbers 0–71 are used to access the pins on the Pmod connectors and pin numbers 72 and 73 are used for the two signal pins on the I2C connector, J6. The pin numbers are assigned so that connector JA pin 1 (JA-01) is digital pin 0, JA pin 2 (JA-02) is digital pin 1, and so on.
Pins 0-7 are on connector JA, pins 8-15 on JB, pins 16-23 on JC, pins 24-31 and so on. Refer to the tables in Appendix C for detailed information about the pin mapping between Pmod connector, logical pin number, and PIC32 microcontroller pin number and pin function.
When using the ChipKIT Pro MX4 with the 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.
5.1 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 the DAC output to be used as a programmable reference for analog comparator 1.
5.2 Push Buttons and LEDs
The ChipKIT Pro MX4 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 configured 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. Note that the button circuitry will effectively act as a 10K ohm pull-up resistor when the button is pressed and a 20K ohm pull-down resistor when the button is not pressed. This will not interfere with most normal uses of the I/O pins if the buttons are not being used.
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:
Page 11 of 37
ChipKIT Pro MX4 Reference Manual
Copyright Digilent, Inc. All rights rese rved.
Other product and company names mentioned may be trademarks of
their respective owners.
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
5.3 RC Servo Connectors
The ChipKIT Pro MX4 provides eight 3-pin RC hobby servo connectors, labeled S1-S8, for direct control of servos in robotics and other embedded hardware actuator applications. The connectors share the I/O pins with Pmod connector JC. Individual I/O pins may be accessed through the JC connector if they're not being used to control a servo.
RC Servos use a pulse width modulated signal, PWM, to control the servo position. The 16-bit timers in the PIC32 microcontroller have the ability to generate PWM signals using the output compare registers. However, it is also possible to use timer interrupts to accomplish this same thing. Using timer interrupts allows a single timer to be used to control the signal timing for all eight servo connectors.
The servo connectors on the ChipKIT Pro MX4 board are intended to be driven using timer interrupts rather than directly by the pulse width modulators in the internal timers. This frees the pulse width modulators for other uses, such as DC motor speed control. Digilent has a reference design available that illustrates using timer interrupts to control signal timing for the PWM signals to control RC servos.
When using the MPIDE development environment, the Servo library can be used to drive servos attached to these connectors. The symbols PIN_S1 through PIN_S8 can be used to refer to the servo connectors being used.
The following give the correspondence between servo connector, MPIDE digital pin number, and microcontroller I/O Port register and bit position:
S1 – PIN_S1, digital pin 16, RG12
S2 – PIN_S2, digital pin 17, RG13
S3 – PIN_S3, digital pin 18, RG14
S4 – PIN_S4, digital pin 19, RG15
S5 – PIN_S5, digital pin 20, RG0
S6 – PIN_S6, digital pin 21, RG1
S7 – PIN_S7, digital pin 22, RF0
S8 – PIN_S8, digital pin 23, RF1
There are three options for supplying power to the servo connections:
A common power bus (BRD_VU) for the ChipKIT Pro MX4 and servos
Separate on-board power busses for the ChipKIT Pro MX4 (BRD_VU) and the servos (VS)
An on-board power bus for the ChipKIT Pro MX4 (BRD_VU) and an external power bus for servos
For the first case above: Install a shorting block on jumper JP1 to connect the VS servo power bus to the BRD_VU power bus. The servo power bus is then powered from the same source as the BRD_VU power bus. Powering a large number of servos from USB power is not recommended. Pin header jumpers and shorting blocks such as JP1
Page 12 of 37
Loading...
+ 26 hidden pages