NU32: Quickstart

From Mech
Revision as of 16:26, 4 January 2013 by NickMarchuk (talk | contribs)
Jump to navigationJump to search

This is a quick-start guide to programming the NU32, using the bootloader and the PICkit3.

If you are looking for more details, take a look at NU32: Starting a New Project and Putting it on the NU32 and NU32: A Detailed Look at Programming the PIC32 on the NU32

Before you start

You should complete the instructions in NU32: Software to Install if you have not already. Specifically, you need to

  • download and install the MPLAB X IDE and the MPLAB XC32 Compiler
  • download the NU32 Utility computer application
  • install drivers for the FTDI USB-to-Serial chip

Test the bootloader

First, make sure your NU32 is working. Use the NU32 Utility to load NU32_HelloWorld.hex to test your NU32 and the Utility.

When the hex file has been loaded, press the User button on the NU32. The LEDs will blink. If they do not blink when you press User, try to load the hex file again, and show the board to your TA for extra help.

Test MPLAB X

Now, create an MPLAB X project to compile the HelloWorld code that blinks the LEDs. This time, the LEDs will blink when User is not pushed. When you run the code, the LEDs should stop blinking when you push User.

Use the NU32_HelloWorld_files.zip to create a project for the NU32 and compile in MPLAB X with XC32. app.ld must be located in the folder with your .c file, and added to the Project in the Linker Files folder. Load the hex file with the Utility.

If the code does not run (the LEDs do not blink by default), double check that app.ld is located in your project folder. Use the "Clean and Build" (hammer and broom) button in MPLAB X is recompile your code to force MPLAB X to look for the new linker file.

Test the PICkit3

If you don't want to use the bootloader and the Utility, and have a PICkit3 programmer, you can program the NU32 directly from MPLAB X.

Build a project with NU32_HelloWorld_standalone_files.zip. Note that you do not need to include a linker file (.ld) in your project - MPLAB X will use the default linker (procdefs.ld). But you need to be sure to include some extra code in your main.c file, because the bootloader called some functions to make the PIC32MX795F512L run at 80MHz and enable some pins.

Plug the PICkit3 into the NU32, lining up the white triangles. Press the "Make and Program Device" button in MPLAB X (green downwards arrow) to program the NU32.

Projects with the standard NU32 functions

The NU32 board has dedicated several pins on the PIC32MX795F512L to special funtions - A4 and A5 are LEDs, C13 is the User button, D14 and D15 are for programming the NU32 over UART4, and F2 and F8 are for communicating with the computer with UART1. These pins should not be used for any other function, unless you are very careful.

These functions can be set up to their dedicated functions by including NU32.c and NU32.h in your project.

Use the NU32_BasicTemplate.zip to start all of your projects. Remember to include app.ld!

Stand-alone projects with the standard NU32 functions using the PICkit3

Use NU32_BasicTemplateStandalone.zip to start all of your projects with NU32.c and NU32.h using the PICkit3.