This blog series explains how to use the Educational BoosterPack LCD with a Hercules LaunchPad.
The Educational BoosterPak MKII is a hot item. It has many sensors on board. and a joystick, a buzzer, a 3-colored LED, buttons and a microphone.
And also a very nice color LCD screen.
The first post was an intro to my driver library for that LCD. This time we'll do the first easy steps: We'll use the Hercules Generic I/O module to control the LCD behavior.
The LCD signals
Next to the power supply, we have to control 3 types of signals to the LCD.
- A Reset and Data/Command line. Two lines that determine the behavior of the screen.
- A signal that controls the intensity of the backlight,
- and a set of 3 signals for the communicaton of data and commands.
In this blog, we'll dive into the Reset and Data/command line.
Generic I/O
Like all microcontrollers, Hercules has a set of generic input/output pins (GIO). These are pins that we can directly control from within our firmware. We can drive them high and low.
In our library, we will not use any input lines. Our LCD screen is an output design. We don't need to read any signal from that LCD. We only write to it.
There are two signals on the LCD driver that are go candidates for GIO control: The reset and the data/control signal.
The reset signalis called nRST (in the schema, you see that there's a line above the RST characters. That means that the signal is active low.
If we drive the GIO pin that's connected to that signal high, the LCD is not in reset, if we drive the signal low, we reset the LCD display.
When we read the schematic of the BoosterPack, we see that this signal is connected to connector J2, pin 17.
The data/control signal switches the LCD between two modes. Listen to commands, or accept data.
An example of a command is: invert the screen, set resolution, ...
The name of the signal is D/nC (the character C in the schema has a line above it).
This indicates that when we have to set the signal high in the firmware when we want to send data to the display. When we want to send a command, we have to pull the signal low.
The D/nC signal is connected to J4, pin 31
Hercules GIO configuration
We'll mount the Educational BoosterPack on the leftmost postion of our hercules LaunchPad. We can then see what LCD signals match what Hercules pins.
That nRST position matches with the Hercules pin 3 of GIO port B.
The D/nC signal connects to pin 0 if port A.
We'll have to enable the GIO module in HALCoGen, verify that the multiplex options for those pins are set to GIO, and set both pins as type output.
On the PINMUX screen, you see that one particular pin of your microcontroller can serve multiple purposes. We assign the I/O function to the pins that are connected to GIOB[3] and FIOA[0].
Last action is to set both pins to output
HALCoGen will generate the firmware code to put our Hercules controller's GIO block in the correct status. It will set the right bits in the right registers to activate GIO, set the multiplexing and set the I/O direction of our two pins to output.
It will also generate a GIO API for us. A set of functions that help us to work with those pins.
We'll use two of those functions. One to initialize the GIO hardware( apply the settings we've clicked in HALCoGen). And one to drive our nRST and D/nC lines high and low.
Firmware
The full source of library and example is attached to the first post, as a Code Composer Studio project. The HALCoGen configuration files can be found in the HALCoGen folder of the project.
The parts of the source where we use the GIO functions are in the LCD library folder, HX8353E.
In HX8353E.c, we first include the GIO API definitions:
#include "HX8353E.h" gioPORT_t *_portReset; // the port the signal line is on uint32_t _pinReset; // the pin the signal line is on gioPORT_t *_portDataCommand; // the port the signal line is on uint32_t _pinDataCommand; // the pin the signal line is on _portReset = gioPORTB; _pinReset = 3; _portDataCommand = gioPORTA; _pinDataCommand = 0;
In the lib's screenInit() function, we prime the GIO module:
gioInit();
And in several places of the code, we drive the nRST and D/nC:
gioSetBit(_portReset, _pinReset, 1); // ... gioSetBit(_portReset, _pinReset, 0); // ... gioSetBit(_portDataCommand, _pinDataCommand, 0);
That's how we control those two GIO signals. Have a read into the screenInit() and screenBegin() functions of the library. Try to understand what's happening there.
Top Comments