Difference between revisions of "NU32: Quickstart"

From Mech
Jump to navigationJump to search
Line 11: Line 11:
* install drivers for the FTDI USB-to-Serial chip
* install drivers for the FTDI USB-to-Serial chip


== Test the bootloader ==
== Test the bootloader, 1.2.1 ==


First, make sure your NU32 is working. Use the NU32 Utility to load [[Media:NU32_HelloWorld_hex.zip | NU32_HelloWorld.hex]] to test your NU32 and the Utility.
First, make sure your NU32 is working. Use the NU32 Utility to load [[Media:NU32test.zip | NU32test.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.
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
== Test MPLAB X ==


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).
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.


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.
Use the [[Media:NU32_HelloWorld_files.zip | 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.


Now click Program. When the message Programming Complete! appears, click Run, and the program will execute.
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.


Image of complete program
== Test the PICkit3 ==


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.
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.


== Test MPLAB X, 1.3.1 ==
Build a project with [[Media:NU32_HelloWorld_standalone_files.zip | 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.


Now we will create an MPLAB X project to test your installation of MPLAB X.
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.


Download [[Media:SimplePIC.c | SimplePIC.c]] and [[Media:NU32bootloaded.ld | NU32bootloaded.ld]].
== Projects with the standard NU32 functions ==

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.'''
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.'''
Line 41: Line 63:
Use the [[Media:NU32_BasicTemplate.zip | NU32_BasicTemplate.zip]] to start all of your projects. Remember to include app.ld!
Use the [[Media:NU32_BasicTemplate.zip | NU32_BasicTemplate.zip]] to start all of your projects. Remember to include app.ld!


== Test the PICkit3, 1.2.2 ==
== Stand-alone projects with the standard NU32 functions using 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 [[Media:NU32_HelloWorld_standalone_files.zip | 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 [[Media:NU32_BasicTemplate_standalone.zip | NU32_BasicTemplateStandalone.zip]] to start all of your projects with NU32.c and NU32.h using the PICkit3.
Use [[Media:NU32_BasicTemplate_standalone.zip | NU32_BasicTemplateStandalone.zip]] to start all of your projects with NU32.c and NU32.h using the PICkit3.

Revision as of 18:16, 17 January 2013

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, 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.