Page 144 - Making PIC Microcontroller Instruments and Controllers
P. 144
wHElt a D HOW Wlll I KI{OW lF ll ls wonKNG? 135
'"Timeouf'
The DEFINES in the first program segment define the variables being used.
"Label"
and are optional and are used to allow the prcgram to cofltinue if characters
are notreceivedin a timely manner Timeout is specifiedin milliseconds See the more
aletailed discussion in the compiler manual. In our case, the timeout means iiat the pro-
gram will jump to the sendirg routine whenever there is nothilg in the receiver buffer
The receiver buffer has preference as set up. However, you need to keep in mind that
the receive buffer is only 2 bytes long, so we cannot linger on the send side too long
before checking on the receive buffer again.
Thing' lo keep in mind when fecei\ ing informariun:
I Even though certain control characters do not show up onscreen, ihey will still be
counted as characters unless lhey are fillered out.
I Some characle$ may not be implemented at all dependirg on the chdracter set rec-
ognized by the software in the two processors. This means that the filters you design
have to be carefully designed to take care of all possjbilities
I The receiving buffer is only two characters long. This is a very impo(ant
consideration.
I weha\enot trkenan] precruliLrtls ellor' and'oon.and
lot lransmi.siodlcceplion
that can get more complicaled than we need to cover at this level of our expertise
Meaning that we will assume there aJe no hardware errors to distulb what we alle
doing.
We can write a short program (see Program 8 3.) to receive and display information
on the LAB-XL Since the infonrution will be displayed on the LCD, we have to include
all rhe u'ual code lor lhe I CD in uur program.
8s232 communications (Prosram lo receive and displav inrormalion
i::ni4tigifi!9il:
lrom the cornpuier)
CIJE]AR
DEFINE OgC 4
DEFINE I,CD DREE PORTD define LCD registers and bits
DEFINE ICD-DBIT 4
DEFINE I,CD-RSREG PORTE
DEFIIIE I.CD RSBIA O
DEFINE I,CD ERTG PORIE
DEFIIIE 'JCD EBIT 1
CHAR VAR BYTE variables used in lhe rouLine
storage for seriat character
COL VAR BI4IE
ROW VIIR BYTE
KEY VIIR BYTE
I,ASTKEY VAR BYAE las! key storage
a.DcoNl = %00000111 set PORTA and POPTE to digitaL