Friday, December 16, 2011

Using the UART on the PIC32 Explorer 16 Board

Using the LEDs and buttons on the Explorer 16 development board gives a user the ability to interact with a program running on the PIC32, but it is a brutally limited form of interaction. To do any serious interaction one would want some kind of console environment. An easy way to create that is to use the RS232 port on the Explorer 16 board to create a communications link with the Windows host system. Unfortunately my Windows system does not have any RS232 ports (they are becoming increasingly rare on new motherboards). To get around this I am using a USB to RS232 adapter that runs some variant of the Prolific USB to RS232 chipset. I also needed a terminal emulator to run on my Windows system so I could communicate on the RS232 port. Hyperterminal, the old terminal emulator of choice, has been removed from recent version of windows, so after some web searching I found a replacement called RealTerm. This program has some powerful features for controlling an RS232 connection and I found it very easy to use. Now armed with an RS232 connection and a terminal emulator I programmed the PIC32 with a UART demo program from the C32 compiler's peripheral library demo folder. The demo is called "uart_basic" and is found in the:
<install path>\Microchip\MPLAB C32 Suite\examples\plib_examples\uart\uart_basic 
directory. The demo is supposed to present the user with a menu of commands where the user selects one by entering the number given for that command. Unfortunately, after programming the PIC32, connecting the RS232 cable, and starting the terminal emulator, nothing happened. After some debugging I tried restarting the Prolific device driver by disabling it and then enabling it in the Windows Device Manager. That solved the problem and the demo performed as expected.
Tip:
RealTerm is an excellent replacement for Hyperterminal, offering some powerful RS232 debugging tools.

Tip:
If you are having trouble using a USB to RS232 adapter, try restating its device driver by disabling and then enabling the device in the Windows Device Manager.

No comments:

Post a Comment