Page 1 of 1

Debugging PIC flow charts using a serial port

Posted: Mon May 13, 2013 11:26 pm
by kersing
Sometimes flowcharts just don't do what is expected when the code runs on a chip. There are several ways to debug this, one way to debug is to attach a display module of some kind (LCD/gLCD) and show debug messages on it. Another way is to write debug messages to a serial port.
For those cases where serial output would be a good solution, but the RS232 component is not available or undesirable, the attached macros (Flowcode 5) implement a software transmit only serial port using one processor pin.

The macros implement a 9600,8,n,1 software serial port, by default on port A1. To change the port adapt all occurrences of the output icon to the desired port/pin (one in DebugInit, four in DebugSendChar). Output string length is limited to 20 characters.

To use the macros, import all three macros into a flowchart. At the start of main include a 'Call Macro' component for DebugInit (this sets the output to idle state). Call the DebugSendString macro wherever debugging output is required.

Hardware required:
Use a USB-TTL serial adapter or an RS232 port with level convertors. For USB-TTL serial adapters, connect the output pin to the RX wire of the adapter and connect GND of the adapter to ground of the circuit. Do not connect TX and 5V! Access the data using any available terminal program set no handshake, 9600 bps, 8 bits, no parity, 1 stop bit.