USART Dynamic Driver Project Using chipKIT™ WF32

 Objective

This example project uses the USART Dynamic Driver Library to control a single USART. A computer based terminal program (e.g. Tera Term or CoolTerm) is used to transmit a character to the PIC32 USART. The PIC32 will then increment the ASCII value of the character by one, and transmit this new character back to the terminal program. In other words, if you transmit the character "b" to the PIC32, it will reply with the character "c".

The hardware for this project uses the chipKIT WF32 board from Digilent Inc.. This board uses an FTDI USB to UART converter, which connects to the USART1 TX and RX pins (U1TX, U1RX) on the PIC32.

usart_hw.png
Click image to enlarge.

The "Project and Source Files" download (see below) contains a fully functional project. It can be used as an example and requires no modifications. To gain a deeper understanding of how to use the MPLAB® Harmony Framework, we recommend you generate the project and source files yourself by following the step-by-step procedure below.

 Materials

Hardware Tools

Tool About Purchase
chipkit-wifire-50px.png
chipKIT™ WF32
Development Board
hwtool-50px.png
chipKITTM PGM
Programmer/Debugger

Software Tools

This project has been verified to work with the following versions of software tools:
MPLAB® X IDE v3.25, MPLAB® XC32 Compiler v1.40, MPLAB® Harmony v1.07.01

Because we regularly update our tools, occasionally you may discover an issue while using newer versions. If you suspect that to be the case, we recommend that you double check using the same versions that the project was tested with.

Archived versions of our tools can be found on the following Microchip websites:
MPLAB Harmony (see "Archived Downloads" tab)
MPLAB X IDE and XC32 Compiler (see "Downloads Archive" tab)
Note that multiple versions of all these tools can co-exist on the same computer.

Tool About Installers
Installation
Instructions
Windows Linux Mac OSX
MPLAB® X
Integrated Development Environment
MPLAB® XC32
C/C++ Compiler
MPLAB® Harmony
Integrated Software Framework

Exercise Files

The contents of the following zip file need to be placed in this directory:

<Harmony install path>/apps/training
(example Harmony install path = c:/microchip/harmony/v1_07_01)

If this is not done, the MPLAB® X IDE will not be able to find all source files, and the project will not build successfully.

File Download
Installation
Instructions
Windows Linux Mac OSX
Project and Source Files

 Procedure

The "Project and Source Files" download provides a fully functional project. It can be used as an example and requires no modifications. The following steps below provide instruction on how this project was created.

1

Create a new MPLAB® Harmony project

The Target Device used on the chipKIT™ WF32 is the PIC32MX695F512L.

2

Use the MPLAB® Harmony Configurator (MHC) to configure the PIC32 clocks

3

Use MHC to configure the USART

4

Use MHC to generate the code

5

Add application states and application variables to your project.

6

Create a handle for the USART Driver, then initialize the handle by opening the driver.

7

Add the transmit and receive states to your application state machine.

8

Connect the development board to your computer, then select the XC32 compiler version and programmer/debugger for the project

The mini USB cable is used to power the board, and to send and receive characters on the USART.

9

Build, program and run your project

 Results

Your development board is now ready to send and receive characters on the USART. Start your terminal emulation program with the following configuration to test the results. Note how the PIC32 increments the ASCII value of the character you transmit by one, before echoing it back to you.

  • Baud Rate: 9600
  • Data: 8-bit
  • Parity: none
  • Number of Stop bits: 1
  • Flow control: none

 Conclusions

You now have the ability to communicate with the PIC32 over the USART. This can be particularly useful while debugging (e.g. transmit a register value, or indicate when a specific section of code is executed). You have also learned how to add your own application variables and states to an MPLAB® Harmony project.

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.