
When working with an embedded system it is often useful to connect the system up to a computer to allow for external monitoring of the system or to integrate an aspect of the embedded functionality into the PC itself. One of the simplest methods for achieving this is to use the hardware serial bus or UART that is built into most common microcontroller devices.
The Flowcode RS232 component provides users with this connectivity functionality.
Step 1: Configure the Flowcode RS232 component properties
The RS232 component properties can be found by clicking on the small menu at the top of the RS232 component and selecting properties from the list. There are several options: BAUD rate stands for bits per second so the actual byte throughput will always be 10 times lower then the baud rate. Hardware flow control will stop data from flowing out until the remote terminal has signalled that it is ready to receive. Echo mode will instantly retransmit any incoming data.

Step 2 Bridging the connections
To connect the embedded system to the computer there will need to be some kind of hardware bridge for the data to flow along. If your computer has a serial port on its motherboard (9-way D-type) then you will be able to use our EB015 RS232 E-block to connect to the PC via a straight through serial cable. Otherwise you will be able to use one of our many USB related products to connect to the PC via a USB cable.
Step 3 Configure the Computer
The computer side of things also needs to be configured. For demonstration purposes we will be using Hyperterminal, which is supplied as standard with most versions of Windows. Windows Vista does not include Hyperterminal as standard so you will have to download it seperatley.
To open Hyperterminal simply click on Start and Run, type in hypertrm and press OK. Create a new connection that uses the COM port that is assigned to your serial port or USB232 board. The COM port number can be found by looking under the Ports section of Windows device manager. Configure the PC so that it uses a BAUD rate to match that of the embedded system. Set the data bits to 8, the parity to none, the stop bits to 1 and the flow control should be set to none or hardware depending on your Flowcode settings.

Step 4 Programming Flowcode
Data can be sent to from the microcontroller to the PC by using the SendRS232 hardware macro and similarly data can be received by using the ReceiveRS232 hardware macro. The SendRS232 macro allows you to send bytes or strings to the computer. Each byte received by the computer will be interpreted as ASCII data so sending a byte value of 48 represents ASCII character β€0β€. The ReceiveRS232 macro will wait for a specific amount of time for an incoming byte. If a byte is received then the macro will return immediately with the byte data that has been received. However if a byte is not received then the macro will wait for the timeout (milliseconds) to end before returning. If the timeout is reached without an incoming byte then the macro will return the value 255. Therefore if the data returned from the recieveRS232 macro is less then 255 then an incoming byte has been received. A timeout of 255 makes the receive macro wait forever for an incoming byte, however this value of timeout is not recommended for a reliable system as it is essentially a blocking function.
Taking this further
Interrupts
You can take this further by adding interrupts to jump to specific macros when a byte has been detected on the incoming hardware buffer. For more details of this refer to the adding interrupts to FCD files application note available from here.http://www.matrixmultimedia.com/mmforum ... =26&t=4797
Sending numbers as ASCII
To send numbers or variables as ASCII simply use the String function "ToString" located in the string manipulation icon to convert the numeric data to a string of ASCII characters.