Apr 21, 2011

Using RTS/CTS on the NetBurner 5272

Hardware handshaking is not enabled by default on the NetBurner 5272 Dev-100 board. I was using UART-1 (as opposed to UART-0) on the development board to communicate with a touch panel display and for reliable behavior I needed to use the handshaking lines. While these steps are specific to a particular NetBurner module on a particular development board I hope to provide enough information that a programmer can easily translate the steps for other boards and modules. For any module other than the 5282 it will be necessary to consult the Freescale module's user guide to find the proper control port settings.

Schematic Reading 101

The first step starts with the schematic for the development board. In my case they were located under the nburn\docs\platform\schematics folder. There were multiple versions and I used the MOD-DEV-100-SCH-R1p08.pdf. The area of interest was on page 8 where you see the serial port circuitry. The title block on the page is listed as "Async Serial". Following pins 7 and 8 from the RS-232 connector over to the left leads you to a net name of UART1-RTS for pin 8 and UART1_CTS on JP10 Header 2 for UART1_CTS. The first step in enabling handshaking is going to require that we place a jumper on JP10 across pins 1 and 2.

The next step is to find these net names elsewhere on the schematic. In this case the TTL Level Serial signals  in the upper left on the same page holds the information we need. On J11 pins 6 and 8 we can see the same net names. If we follows those over to the right we can see that CTS goes to JP1 and RTS leads to JP2. The schematic indicates which pins to jumper for either the 5272 or the 5282. For the 5272 we will need to jumper pins 2 and 3 on both  headers.

I find it helpful to have jumpers of different colors. Since I'm modifying my development board for a particular project I want to be able to "unjumper" the board to get it back to the factory condition. Since the board currently has a number of black jumpers, I just used red and blue jumpers for my modifications.

 SNAGHTML1016b81c

ColdFire Alternate functions

When pins can be used for more than one function  on the ColdFire 5272, we need to use the GPIO control ports to configure the function we want. Some function is always defined as the default. In this case,  for RTS/CTS on URT1, we want the alternate function so we must explicitly set the values. The information on how to do this isn't in the NetBurner documentation but instead, it can be found in the Freescale MCF5272UM  manual (MCF5272 ColdFire Integrated Microprocessor User's Manual).  Specifically we are interested in Chapter 17 on the General Purpose I/O Module. The port settings of interest are on the Port D Control Register (PDCNT). In the rev 3 version of the manual we want page 17-9 (pdf page 403).  The specific table entry is for Bits 7-6 and 5-4.  The  control maps between QSPI-CS2  and UART1-CTS for one entry and between IRQ5 and UART1_RTS for the other entry.

Somewhere early in the boot process you need to invoke the bit banging methods for setting up the functions. Shown below is one approach for doing this. (Note for this code to work you need to include the proper header for the module. If you are in a device project you will already have the path to nburn\MOD5272\include in your paths and you can just use:
#include <sim5272.h>.
If you are putting this in a library then you have to the use the longer form:
#include <../MOD5272/system/sim5272.h>

image

Setting the Serial Port handshaking options

The final step is to configure your serial port settings to specify that RTS/CTS handshaking should be used. In my standard NetBurner library I have a serial port class and it contains the method shown below for configuring handshaking. There are setter methods for the m_RtsHandshake member variable which as you can see from the code is an enumerated value. The user creates an instance of the class, changes any settings where the defaults aren't appropriate and then issues an Open() command on the instance of the port, which among other things calls the EnableRtsHandshake() method below.

image

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.