Getting Started

(lily) #1

Chapter 6: C Functions and Program Structures


ollers are buried deep in some device where they run in merry
lation from the rest of the world. Their programs are burned into them and
t there are many instances when we might want to communicate
, which is fine
hanging the
g the PC’s RS232 serial
icrocontroller through its
ransmitter, USART, peripheral.
on the transmission speed in data bits
ber of bits per data unit, Data Bits, the parity of the
r of stop bits, Stop Bits, and Flow Control. (Refer to
m section of Chapter 2 for the required
acy from even before
stuff for
, get Jan
elson’s Serial Port Complete (www.lvr.com

Projects..........................................................................................................


Is anybody out there? Communicating with a PC.....................................

Most microcontr
iso
never change. Bu
with a microcontroller. The Butterfly uses a joystick and an LCD
for its built-in applications. For anything more complex, like c
microcontroller software, nothing beats usin
communications port to communicate with the m
Universal Synchronous Asynchronous Receiver T
The microcontroller and the PC must agree
per second, Baud rate, the num
data, Parity, the numbe
Constructing Your Development Syste
settings) All this information is somewhat arcane and is leg
Teletype machines. Fortunately the USART takes care of most of this
yo
x


u, so you don’t need to understand it. If you are really interested
A ).


the PC and receive
In this section we will develop a generic command
later programs. In this project we will
a demonstration that let’s the PC send a command name

. The Butterfly will respond with text.


ell beyond our C
rd about it yet. We
r knowledge. You should have no

What we need is a method to send commands and data from
responses from the Butterfly.
interpreter skeleton that we will reuse in
use this skeleton to build
and a number to the Butterfly


We will put this software in four files:
PC_Comm.h
PC_Comm.c
Demonstrator.h
Demonstrator.C


The PC_Comm files have many things in them that are w
training at this point, so just copy them and don’t think too ha
will revisit each function later as we increase ou

Free download pdf