Difference between revisions of "NU32v2: Serial Communication with the PC"

From Mech
Jump to navigationJump to search
Line 73: Line 73:


== Processing ==
== Processing ==
'''To Do'''


== MATLAB ==
== MATLAB ==

Revision as of 17:29, 25 January 2011

Under construction NDM 1/25/2010

The NU32v2 has the ability to talk directly with a computer over a virtual serial port connection. This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer.

Overview

The NU32v2 uses an on board FT233RL chip from FTDI to convert RS-232 serial communication to USB. Using drivers from FTDI, the communication can be opened by any program that can access a serial port. On the NU32v2 side, sample code has been created to enable the Serial module on the PIC32. Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer side, several programs that can access the serial connection are discussed, including PuTTY, Processing and MATLAB.

Details

The FT232RL chip is hardwired to the UART3 module on the PIC32M795F512L. The Receive (RX) pin, G7, and Transmit (TX) pin, G8, are also brought out to the sides of the NU32v2 board.

The NU32v2 Serial Bootloader uses the UART3 module at 115200 baud, as does the code below, but this can be changed as desired.

Library Functions

This code contains functions to read and write over the serial port.

NU32v2.h contains function prototypes, in addition to the serial functions, to initialize the LEDs on the NU32v2 board as well as the bootloader button.

NU32v2.c contains the functions. Neither this file or the .h file need to be changed to work.

The functions that control the serial communication are:

  • InitSerial()
  • WriteString()
  • PutCharacter()

NU32v2_serial_example.c contains example code that shows how to uses the functions. It also contains the ISR for UART3, with an example of how to receive characters.

Sample Code

To initialize the serial communication, call InitSerial():

init

To write a string to the computer, use WriteString()

write

To write a string with the value of a variable in it, use Sprintf() and WriteString()

sprintf

To receive characters in an interrupt, use this ISR

isr

PuTTY

PuTTY is a terminal program that will let you open the virtual serial port created by the FTDI driver.

Directions to install PuTTY can be found in NU32v2: Software to Install#PuTTY Terminal Emulator

Before launching PuTTY, note the name of your COM port, same name as you use in the Serial Bootloader Application.


Launch Putty.exe. Set up your communication by:

  • Selecting the 'Serial' radio button

Select the 'Serial' branch in the tree on the bottom left.

  • Enter the name of your COM port in 'Serial line to connect to'
  • Enter 115200 in 'Speed (baud)'
  • Change 'Flow control' from 'XON/XOFF' to 'None'

Go back to the 'Session' screen by selecting the 'Session' in the top left of the tree.

  • Name your settings in 'Saved Sessions' and click 'Save'
  • Click the 'Open' button

Processing

To Do

MATLAB

More Information

More detailed information on how the the serial module on the PIC32 can be configured is on this page (DNE).