Start
Typical
MCU Tasks
Microcontroller
Mode
Watch
This!
Put the GP-22050 to Work
Closing
the Lid
Sources and
PDF
WATCH
THIS!
In
the case of the GP-22050, arbitrary waveforms
are born from a configuration/data file and
a raw hexadecimal or binary data file. The GP-22050
package includes a bunch of example files that
cover all of the bases. You can enter configuration
data to the best of your ability into the 8PI
control panel, which is the GUI that aids in
the configuration of the GP-22050 (see Photo
1, p. 63). You’ll get a configuration/data file
in return by simply saving the configuration
data you entered.
|

(Click
here to enlarge)
|
Photo
1—By simply saving this configuration information,
I created a configuration/data file with
all of the chosen parameters laid out in
text form. All that was left to do was fill
in the control and data patterns needed
to drive the LCD. |
The
entries you see in Photo 1 show that I considered
everything I needed to drive the LCD in 4-bit
mode using the GP-22050’s control and I/O interface.
As I mentioned earlier, the 6 control/trigger
bits beyond the 16 I/O bits offered by the GP-22050’s
I/O interface were used for control and triggering
purposes. Because I didn’t need any triggering
to drive the LCD, I allocated all of the six
control pins to control tasks. As it turned
out, the only control signal I needed for the
LCD was the Enable (E) signal, which I assigned
to the least significant bit of the 6-bit control
bit chain.
Initializing
an HD44780-based LCD is a relatively slow process
in the beginning. So, to make sure I could meet
the initialization timing restrictions and still
operate the LCD fairly quickly, I chose to run
the GP-22050’s internal clock at 1 kHz, which
resulted in 1-ms clock cycles.
To
conserve microcontroller I/O, I run HD44780-based
LCD panels in 4-bit mode. I do the same with
the GP-22050. The least significant 4 bits of
the GP-22050’s 16-bit I/O port are dedicated
to the LCD’s D4–D7 data I/O pins, which the
LCD uses in 4-bit mode. Bit 4 of the GP-22050’s
I/O port services the LCD’s backlight by way
of a ULN2003 high-current driver IC. Toggling
the LCD’s RS pin differentiates commands and
data sent to the LCD.
I assigned bit 5 of the GP-22050’s I/O
port to LCD RS pin duty.
After
saving the configuration data, I opened the
resultant file (lcd_driver.ini) and found the
command structure shown in Listing
1. Track through Listing 1 and compare the
commands (which begin with the @ character)
with the graphic configuration choices I entered
in Photo 1. As you can see, Listing 1 is a skeleton
template that consists of essential commands
that define the GP-22050’s control and data
I/O pin assignments as well as the GP-22050’s
clock state, operating frequency, and trigger
pattern. The next step involved filling in the
binary patterns I wanted to see emitted on the
GP-22050’s control and data pins.
I
started by defining the LCD control sequence
to toggle the LCD E pin. Initializing the HD44780-based
LCD panel in 4-bit mode required a minimum of
a 4.1-ms delay following the first function
set initialization command. The wait time between
subsequent function set commands was 100 µs.
As a result, setting the minimum wait time to
exceed 4.1 ms would have been overkill after
the first function set wait time had expired.
However, I didn’t really care in this case because
LCD update speed wasn’t a factor. If faster
LCD update speeds were required, I could have
simply coded a separate LCD initialization configuration/data
file, run it, and then loaded and run another
configuration/data file, which would have performed
only the LCD data transfer tasks.
The
control sequence defined in Listing
2 was performed each time data was presented
on the GP-22050’s data bus. (The complete version
is posted on the Circuit Cellar FTP site.) I
could have included multiple control files in
a configuration/data command set, but only the
last control sequence coded into the command
set was used. So, only one control sequence
was executed per configuration/data file.
I
couldn’t have but one control sequence in my
configuration/data file, so I set the dwell
before and after the raising of the LCD E signal
to three clock cycles, which resulted in a minimum
six clock cycle (6-ms) delay between characters
and commands issued to the LCD’s HD44780 chipset.
That gave the LCD plenty of time to accept and
execute instructions in the initialization phase
and provide more than enough time for the HD44780
to put characters on the display.
The
same command logic that I used in the control
area applied in the data area. If you continue
along the GP-22050 command chain in Listing
2, you’ll see that I didn’t set the bit to illuminate
the LCD backlight until after the LCD initialization
was completed. Note also that the LCD RS signal
was at a low level for each instruction sent;
it went high to enable communication with the
LCD’s data registers. The coding of the GP-22050
commands was a bit different than writing code
for a microcontroller, but the logic behind
the data patterns and the way the data was transmitted
to the LCD was very similar to the way a microcontroller
would do it.
The
control pulse chain produced by the first four
@data out commands in Listing 2 is shown in
Photo 2 (p. 64). I used a USB-attached, PC-based
Cleverscope CS328 oscilloscope to capture both
the control pin waveforms and the data presented
on the GP-22050’s I/O pins that are configured
as data outputs to the LCD’s data bus.
|

(Click
here to enlarge)
|
Photo
2—The @loop 1 3 command translates to looping
the one line immediately following the @loop
command three clock cycle times. Because
each clock cycle is 1 ms in duration, the
E signal is low for 3 ms, high for 1 ms,
and low for a minimum of 3 ms following
the transmission of a character or command
to the LCD. The E signal pulses and data
follow the commands in the LCD initialization
area of Listing 2. |
Analyzing
the CS328 display from left to right, the first
three LCD E pulses are a result of the @loop
1 3 and @data out 0000000000000011 commands.
Data4 in the logic capture area of Photo 2 is
physically connected to the LCD DB4 data pin
and the GP-22050’s D0 pin. Data5 is connected
to the LCD DB5 pin, configured as the GP-22050’s
D1 pin, and so forth. The fourth LCD E pin pulse
from the left was produced by the @data out
0000000000000010 command. The final two E pulses
are clocking out 0x28 to the LCD data pins.
In 4-bit mode, the high nibble of each ASCII
character is sent first and immediately followed
by the least significant nibble 7 ms later.
I
kicked off the capture session in Photo 2 using
the Operation window in the 8PI control panel.
I selected File mode and loaded the lcd_driver.ini
file shown in Listing 2. To capture the first
six commands shown in Photo 2, I set the step
size value to 6 and clicked the Step button.
Clicking the Start button ran the entire 48-command
sequence, which resulted in what you see in
Photo 3a.
|


(Click
here to enlarge)
|
Photo
3a—Ignore the trash in the background. Focus
on the GP-22050 tied to the four-line LCD
panel. The GP-22050 package comes with a
connector kit that includes three eight-conductor
connectors and five two-conductor connectors.
The quick clips are the Cleverscope logic
probes, which are tied to the four LCD data
lines D4–D7. b—And you thought I just sat
around writing columns in an ivory tower. |