Difference between revisions of "Getting Started with PIC32"

From Mech
Jump to navigationJump to search
 
(37 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page details getting started with the PIC32 board. It discusses what software needs to be installed on your computer.
This page details getting started with the PIC32 board.

Please complete the software section prior to lab 1.

In lab 1, you will assemble a NU32 board, install a bootloader and create a Hello World Program.


= Software =
= Software =
Line 6: Line 10:
We are going to install MPLAB (software used for editing, compiling, and debugging code), the C32 compiler (software to create the program) and the Microchip Applications Library (common source files for programming).
We are going to install MPLAB (software used for editing, compiling, and debugging code), the C32 compiler (software to create the program) and the Microchip Applications Library (common source files for programming).


1. Download and Install MPLAB IDE vX.XX Full Release Zipped Installation located near the bottom of this [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&redirects=mplab page].
1. Download MPLAB IDE vX.XX Full Release Zipped Installation located near the bottom of this [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&redirects=mplab page]. You can save the zip file temporarily to the desktop; you will delete it after installation. Extract the files from the zip file to create a folder on your desktop. Double-click on the setup launcher, run it, and choose "complete setup." Let it install in the default location. (Do not install HITEC-C when prompted.) If MPLAB IDE Document Select appears, you can just close it. Now the MPLAB IDE is installed and you can delete the zip file and extracted folder from your Desktop.


2. Download and Install MPLAB C Compiler for PIC32 vX.XX Academic Version located near the bottom of this [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536656 page] (the academic version is free)
2. Download the MPLAB C Compiler for PIC32 vX.XX Academic Version located near the bottom of this [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536656 page] (the academic version is free). Click "Run" and let it install in the default location.


3. Download and Install the Microchip Applications Library [[Media:MicrochipAppLib_11_18_2009.zip|here]]. This zip file is the library version released on 11-18-2009. More recent versions can be downloaded [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537044 here] but the files may not work with the code listed on the wiki. Extract this folder to C:/Program Files/Microchip (the Microchip folder will be created when you install MPLAB).
3. Download the Microchip Applications Library [[Media:MicrochipAppLib_11_18_2009.zip|here]]. This zip file is the library version released on 11-18-2009. More recent versions may be downloaded [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537044 here] but the files may not work with the code listed on the wiki. Save the zip file to your desktop and extract the files. Run the installer and install to the default. Now you can delete the zip file and extracted folder. '''Note:''' When installing this library, Microchip may prompt you to install .Net software. Click yes if this happens.

= Board Assembly =

The NU32 development board you are going to assemble already has a PIC32 microcontroller soldered on the board. You will be soldering the rest of the components.

Collect the following components from the PIC32 supply bin.
[[Image:nu32_components.jpg]]

{| border="1"
! style="background:#efefef;" | Part Label
!! style="background:#efefef;" | Part Name
!! style="background:#efefef;" | Quantity
!! style="background:#efefef;" | Vendor
!! style="background:#efefef;" | P/N
!! style="background:#efefef;" | Description
|-
| A || 8.0 MHz Crystal || 1 || Digikey ||X979-ND||
|-
| B || 3.3 V Regulator || 1 || Digikey ||LD1117V33 || Input: 4.75 ~ 10 V; Output: 3.3V, 950 mA
|-
| C || Barrel Connector 2.5mm ID|| 1 || Digikey ||CP-102BH ||
|-
| D || Mini USB - B Socket|| 1 || Digikey ||WM17115-ND||
|-
| E || NU32 Board || 1 || NU || ||
|-
| F || 36 Pos Single Row Header Pins|| 2 || Digikey ||WM6536|| '''You will cut these to two rows of 29 pins for the long edges of the board. You will also need a leftover 5-pin header to mount at the short end of the board away from the USB connector. These pins will point upward, opposite the pins on the long edge of the board. This 5-pin header will be used to program the bootloader on the PIC32.'''
|-
| G || 330 Ohm Resistor || 1 || Digikey ||332XBK-ND||
|-
| H || 22 pF Capacitor|| 2 || Digikey ||478-4846-ND||
|-
| I || LEDs|| 5 total || Digikey ||
{|
|1 RED || 160-1084
|-
|4 YEL || 160-1085
|-
|or 4 GRN || 160-1086
|}
|-
| J || 10 uF Capacitor|| 1 || Digikey ||399-3548-ND|| Polarized
|-
| K || 0.33 uF Capacitor|| 1 || Digikey ||399-4299-ND||
|-
| L || 1 uF Capacitor|| 1 || Digikey ||BC1162CT-ND||
|-
| M || 0.1 uF Capacitor|| 10 || Digikey ||478-3192-ND||
|-
| N || 1K Ohm Resistor Array|| 1 || Digikey ||770-81-R1KP-ND||
|-
| O || Sub Miniature Slide Switch|| 1 || Digikey ||401-2001-ND||
|-
| P || Reset Button|| 3 || Digikey ||CKN9102-ND||
|-
| Q || 10K Ohm Resistor|| 1 || Digikey ||10.0KXBK||
|-
|}


The PIC32 is already soldered to the board.
[[Image:nu32_bare_board.jpg]]

Begin soldering components, ending with the header pins.

The capacitor labels can be hard to read, they are color coded here:
[[Image:capacitor_chart.jpg]]

Several components need to be soldered with the proper orientation.
The 10 uF capacitor needs to be soldered with the positive lead towards the PIC.
[[Image:nu32_capacitor.jpg]]

The resistor array needs to have the side with the dot facing the long end of the board.
[[Image:nu32_resistor_array.jpg]]

The indicator LEDs need to have their positive leads toward the end of the board.
[[Image:nu32_indicator_led.jpg]]

The power LED needs to have its positive lead facing the close edge of the board.
[[Image:nu32_power_led.jpg]]

The 3.3V regulator needs to have its back side facing the power jack.
[[Image:nu32_regulator.jpg]]

The finished board looks like this:
[[Image:nu32_complete.jpg]]

Note to program the bootloader onto the board, the programming cable can only be plugged into the last five header pins one way:
[[Image:nu32_program.jpg]]


= Bootloader =
= Bootloader =


'''Note: If you're in lab with the TA, you can ask the TA to install the bootloader for you and skip this step. Once the bootloader is installed on your PIC, you should not have to install it again. This step requires the Microchip ICD2 programmer.'''
A bootloader is a program that enables you to easily install programs on the PIC32 using only a USB cable. Normally, an external programmer is needed for programming the PIC.

A bootloader is a program that enables you to easily install programs on the PIC32 using only a USB cable. Normally, an external programmer is needed for programming the PIC. The bootloader takes hex files created by the MPLAB compiler and programs them on the PIC. Hex files are binary representations of the c code. See the wikipedia page for Hex files [http://en.wikipedia.org/wiki/Intel_HEX here] for more information.


Follow these [[Programming HID Bootloader on PIC32|directions ]] to install a bootloader on your PIC.
Follow these [[Programming HID Bootloader on PIC32|directions ]] to install a bootloader on your PIC.
Line 22: Line 117:
We are first going to test that you installed the bootloader correctly.
We are first going to test that you installed the bootloader correctly.


- Download this HelloWorld [[Media:HelloWorld_PIC32_Hex.zip|hex file]]. (This code flashes all of the LEDs at a 1 second period)
- Download this HelloWorld zip [[Media:HelloWorld_PIC32_Hex.zip|file]] and extract the hex. (This code flashes all of the LEDs at a 1 second period, if you hold down the USER button the period changes)


- Use [[Directions to Load Files to PIC32 with HID Bootloader|these directions]] to load a Hex File with the bootloader.
- Use [[Directions to Load Files to PIC32 with HID Bootloader|these directions]] to load a hex File with the bootloader.


Next, we are going to make a different Hello World program from scratch.
Next, we are going to make a different Hello World program from scratch.


Follow the directions [[HelloWorld_PIC32|here]] to code and program Hello World on to the PIC32 using the bootloader.
- Follow the directions [[HelloWorld_PIC32|here]] to code and program Hello World on to the PIC32 using the bootloader.

Latest revision as of 20:33, 21 April 2010

This page details getting started with the PIC32 board.

Please complete the software section prior to lab 1.

In lab 1, you will assemble a NU32 board, install a bootloader and create a Hello World Program.

Software

This section discusses the software that must be installed on your computer. This software is only compatible with Windows. We are going to install MPLAB (software used for editing, compiling, and debugging code), the C32 compiler (software to create the program) and the Microchip Applications Library (common source files for programming).

1. Download MPLAB IDE vX.XX Full Release Zipped Installation located near the bottom of this page. You can save the zip file temporarily to the desktop; you will delete it after installation. Extract the files from the zip file to create a folder on your desktop. Double-click on the setup launcher, run it, and choose "complete setup." Let it install in the default location. (Do not install HITEC-C when prompted.) If MPLAB IDE Document Select appears, you can just close it. Now the MPLAB IDE is installed and you can delete the zip file and extracted folder from your Desktop.

2. Download the MPLAB C Compiler for PIC32 vX.XX Academic Version located near the bottom of this page (the academic version is free). Click "Run" and let it install in the default location.

3. Download the Microchip Applications Library here. This zip file is the library version released on 11-18-2009. More recent versions may be downloaded here but the files may not work with the code listed on the wiki. Save the zip file to your desktop and extract the files. Run the installer and install to the default. Now you can delete the zip file and extracted folder. Note: When installing this library, Microchip may prompt you to install .Net software. Click yes if this happens.

Board Assembly

The NU32 development board you are going to assemble already has a PIC32 microcontroller soldered on the board. You will be soldering the rest of the components.

Collect the following components from the PIC32 supply bin. Nu32 components.jpg

Part Label Part Name Quantity Vendor P/N Description
A 8.0 MHz Crystal 1 Digikey X979-ND
B 3.3 V Regulator 1 Digikey LD1117V33 Input: 4.75 ~ 10 V; Output: 3.3V, 950 mA
C Barrel Connector 2.5mm ID 1 Digikey CP-102BH
D Mini USB - B Socket 1 Digikey WM17115-ND
E NU32 Board 1 NU
F 36 Pos Single Row Header Pins 2 Digikey WM6536 You will cut these to two rows of 29 pins for the long edges of the board. You will also need a leftover 5-pin header to mount at the short end of the board away from the USB connector. These pins will point upward, opposite the pins on the long edge of the board. This 5-pin header will be used to program the bootloader on the PIC32.
G 330 Ohm Resistor 1 Digikey 332XBK-ND
H 22 pF Capacitor 2 Digikey 478-4846-ND
I LEDs 5 total Digikey
1 RED 160-1084
4 YEL 160-1085
or 4 GRN 160-1086
J 10 uF Capacitor 1 Digikey 399-3548-ND Polarized
K 0.33 uF Capacitor 1 Digikey 399-4299-ND
L 1 uF Capacitor 1 Digikey BC1162CT-ND
M 0.1 uF Capacitor 10 Digikey 478-3192-ND
N 1K Ohm Resistor Array 1 Digikey 770-81-R1KP-ND
O Sub Miniature Slide Switch 1 Digikey 401-2001-ND
P Reset Button 3 Digikey CKN9102-ND
Q 10K Ohm Resistor 1 Digikey 10.0KXBK


The PIC32 is already soldered to the board. Nu32 bare board.jpg

Begin soldering components, ending with the header pins.

The capacitor labels can be hard to read, they are color coded here: Capacitor chart.jpg

Several components need to be soldered with the proper orientation. The 10 uF capacitor needs to be soldered with the positive lead towards the PIC. Nu32 capacitor.jpg

The resistor array needs to have the side with the dot facing the long end of the board. Nu32 resistor array.jpg

The indicator LEDs need to have their positive leads toward the end of the board. Nu32 indicator led.jpg

The power LED needs to have its positive lead facing the close edge of the board. Nu32 power led.jpg

The 3.3V regulator needs to have its back side facing the power jack. Nu32 regulator.jpg

The finished board looks like this: Nu32 complete.jpg

Note to program the bootloader onto the board, the programming cable can only be plugged into the last five header pins one way: Nu32 program.jpg

Bootloader

Note: If you're in lab with the TA, you can ask the TA to install the bootloader for you and skip this step. Once the bootloader is installed on your PIC, you should not have to install it again. This step requires the Microchip ICD2 programmer.

A bootloader is a program that enables you to easily install programs on the PIC32 using only a USB cable. Normally, an external programmer is needed for programming the PIC. The bootloader takes hex files created by the MPLAB compiler and programs them on the PIC. Hex files are binary representations of the c code. See the wikipedia page for Hex files here for more information.

Follow these directions to install a bootloader on your PIC.

First Program

We are first going to test that you installed the bootloader correctly.

- Download this HelloWorld zip file and extract the hex. (This code flashes all of the LEDs at a 1 second period, if you hold down the USER button the period changes)

- Use these directions to load a hex File with the bootloader.

Next, we are going to make a different Hello World program from scratch.

- Follow the directions here to code and program Hello World on to the PIC32 using the bootloader.