NU32: Quickstart

From Mech
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

You can download all of the code on this page here:

  • NU32test.hex - Precompiled .hex "Hello World!" to test your NU32
  • SimplePIC.c - C code for a different version of "Hello World!" to test your installation of MPLAB X
  • NU32bootloaded.ld - Linker file for all code that will use the bootloader to load
  • NU32bootloaded.ld - C code for a different version of "Hello World!" using serial communication
  • NU32.c - C code library for the NU32 functions
  • NU32.h - Header file for the NU32 functions

Test the bootloader, 1.2.1

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

To use the Utility, first plug in the mini USB cable to your NU32 and computer. Then power your NU32 with the wall power and turn on the board so that the red power LED is on. Now open NU32Utility.

Image of utility when first opened

The NU32 board will create 2 virtual serial ports on your computer. In Windows, the ports will be named something like COM10 and COM11, or some two consecutive numbers. On a Mac or in Linux, the ports will named DEV/TTY/##A and ##B. (You can ignore the CU versions).

The left hand side of the Utility is used for loading code onto the NU32. Select the larger of the two ports (so COM11 instead of COM10, or ##B instead of ##A). Click Select HEX and navigate to your .hex file. The NU32 must be in bootloading mode to accept code - LED1 blinks in this mode. You can put the NU32 in this mode by pressing and holding Reset, pressing and holding User, releasing Rest, then releasing User. Or, depending on the code already on the NU32, clicking Request Boot.

Now click Program. When the message Programming Complete! appears, click Run, and the program will execute.

Image of complete program

Using NU32test.hex, if you press the User button, LEDs 1 and 2 will blink out of phase, and stop blinking when you don't push User.

Test MPLAB X, 1.3.1

Now we will create an MPLAB X project to test your installation of MPLAB X.

Download SimplePIC.c and NU32bootloaded.ld.

Create a project in MPLAB X with XC32. Open MPLAB X and click New Project.

Image

Select ...

Image

When the project has been created, a new folder will appear in C:/users/MPLABXprojects/. Put the SimplePIC.c and NU32bootloaded.ld files in this folder. In MPLAB X, right click on source and select add files from, and select the .c file. Do the same for the .ld file in the liker folder.

Image

Select Build, and the bottom of the screen should show build completed.

Image

There is now a .hex file in /dist/build/.

Use the NU32 Utility to put the .hex file on the NU32. Now the LEDs blink all the time, and stop when you hold the User button.

Projects with the standard NU32 functions, 1.4.1

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!

Test the PICkit3, 1.2.2

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.

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

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