The polarity of the LCD’s RS input determines if the
data on its bus is a command or data. For instance, if we
want to send a command to clear the display, we would
call it in this manner:

lcd_send_byte(lcdcmd,0x01);

Sending the character “A” to the display is done in a
similar fashion:

lcd_send_byte(lcddata,‘A’);

The code we’ve just written to transmit bits to the LCD
interface establishes a foundation for the code we will use
to build the LCD initialization function. With that, there
should be no surprises in the lcd_init function:

There’s one more function in our LCD arsenal called
lcd_gotoxy. As you have already ascertained by its name,
the third LCD function allows you to position the cursor
anywhere on the LCD. I used the LCD cursor positioning
function to assemble these front-of-the-line location macros:

#define
#define
#define
#define

line1
line2
line3
line4

lcd_gotoxy(1,1)
lcd_gotoxy(2,1)
lcd_gotoxy(3,1)
lcd_gotoxy(4,1)

At this point, the LCD is ready to rock and roll. We
came down this trail to replace banks of discrete LEDs with
an LCD. So, let’s put some ordnance down range.

Monitoring PIC16F690 I/O Pins

If you haven’t already done so, I suggest downloading
the code package that accompanies this discussion. Once
you have the code in front of you, further examination of
the PIC16F88 routines will reveal the activation of the
PIC16F88’s AUSART (Addressable Universal Synchronous
Asynchronous Receiver Transmitter) in receive-only mode.
You will also find a small display application that converts
any incoming byte into its binary equivalent. The binary
pattern is then displayed on the LCD as a series of ones
and zeros.

The download package also contains a source code file
to drive the PIC16F690. From a coding point of view, the
PIC16F690 is very similar to the PIC16F88. The PIC16F690
uses the PIC16F88 TIMER1 code to implement a 1 mS time
base. However, the PIC16F690’s EUSART is configured for
transmit only.

The I/O port section of the PIC16F690 datasheet shows
us that the data present in the output latch of any PORTC
I/O pin configured as an output can also be read as long as
there is no outside influence connected to the I/O pin being
read. That means we can simulate driving LEDs by simply
writing the desired binary pattern to PORTC and reading it
back. The application running on the PIC16F690 increments
a variable every five seconds and writes the value of the
variable to PORTC. After writing the new value to PORTC,