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 blog series shows how to drive the BoosterPack's LCD from a Hercules microcontroller.
This post assumes you've done the preparation steps from the first 3 posts.
I've received both LaunchPad and BoosterPack from TI.
For the impatient: I've attached the CCS project to this blog.
Download the LCD library
The library is an as-close-as-possible port of the Energia library for this display.
I've published the source on github.
The simplest way to get at the code is to download my repository, and copy the HX8353E folder that can be found under hercules_libraries-master/lcd_hx8353e in the root of your project.
Take care that you add both HX8353E and HX8353E/bitmaputils to your includes in the project properties.
If you use the project that's available by clicking the doload button at the top of this blog, that's already done for you.
Configure the MIBSPI driver
Our display is connected to the pins of Hercules MIBSPI3. The display requires three additional pins to drive the backlight, a data/command selector and a reset line. These have been discussed and configured in blog 2 and 3.
That means that for SPI, we have to configure the clock, MOSI and CS (the display's chip select is connected to CS number2).
We don't need MISO, because the display never sends anything back to us.
First enable the MIBSPI3 driver. We use buffered SPI - we take advantage of that buffer mechanism when displaying bitmap images.
Then enable the Pin Multiplexing for the three SPI lines. This is additional to the PINMUX activities from post 2 and 3.
We're using 2 MIBSPI data formats. One to send 8-bit data. The other for 16-bit.
In the settings below, I've put the moderate line speed of 8000. I've had success with settings up to 30000.
Don't forget to set the clock polarity flag. That's the one that takes care that the data is set up as expected by the LCD (SPI Mode 0).
These two data formats are used in our transfer groups.The library uses three groups. One for 8-bit single shot, one for 16-bit single shot and the last one for a buffered stream of 64 16-bit values.
The two 16-bit groups use the same data format.
The last setting is to make our 3 SPI lines functional and make them outputs. As indicated before, we don't need MISO in our scenario.
Demo
The CCS demo project is available as a zip archive attached at the end of this blog.
The demo draws lines, circles, triangles, text and a bitmap.
Put the BoosterPack jumper J5 on pins 2 and 3. That is needed to drive the LCD backlight. If you see the red light very bright on the boosterpack, it means you have J5 wrong.
Here's a snippet of the demo's main file.
It does exact the same as what you see on tha animation above:
- It clears the LCD to an orange background.
- Then two diagonal blue lines.
- A white circle and a blue filled rectangle and an unfilled one in the middle.
- Clear the screen with black background.
- Type text in white and yellow, using the smallest font.
- Clear the screen again and draw a full screen bitmap.
Rinse and repeat.
/* USER CODE BEGIN (1) */ #include "HX8353E.h" #include "bitmaputils.h" /* USER CODE END */
void main(void) { /* USER CODE BEGIN (3) */ // initialize LCD screenInit(); screenBegin(); while(1) { clear(orangeColour); line(0, screenSizeY()-1, screenSizeX()-1, 0, blueColour); line(0, 0, screenSizeX()-1, screenSizeY()-1, blueColour); delay(500); circle(screenSizeX()/2, screenSizeY()/2, 30, whiteColour); delay(500); setPenSolid(true); triangle(screenSizeX()/2-20, screenSizeY()/2 - 20, screenSizeX()/2 + 20, screenSizeY()/2 - 20, screenSizeX()/2, screenSizeY()/2 + 20, blueColour); delay(500); setPenSolid(false); triangle(screenSizeX()/2, screenSizeY()/2 - 20, screenSizeX()/2 - 20, screenSizeY()/2 + 20, screenSizeX()/2 + 20, screenSizeY()/2 + 20, blackColour); delay(500); clear(blackColour); setFontSize(1); uint8_t text1[] = {"Hercules"}; uint8_t text2[] = {"LaunchPad"}; uint8_t text3[] = {"Educational"}; uint8_t text4[] = {"BoosterPackMKII"}; gText(4, 4, text1, 8, whiteColour, blackColour, 1, 1); gText(4, 25, text2, 9, whiteColour, blackColour, 1, 1); gText(4, 72, text3, 11, yellowColour, blackColour, 1, 1); gText(4, 93, text4, 15, yellowColour, blackColour, 1, 1); delay(500); clear(blackColour); delay(500); drawHerculesMCUs(); delay(1000); } /* USER CODE END */ }
Bitmaps
I've prepared the bitmaps with LCD Image Converter. This utility creates C arrays from 24-bit bitmap files.
Make a 128*128 px image. Import it in de converter. Replicate these settings
The RM46 is a little-endian device.
Push preview, and copy the content of the popup window.
You can paste it over the HerculesMCUs[] array in the file bitmapdemo/16bitdemo.c.
The firmware will then show your image.
Have fun.
Blog Series |
---|
Educational BoosterPack MKII and Hercules LaunchPad - LCD Driver part 1 |
Educational BoosterPack MKII and Hercules LaunchPad - LCD Driver part 2: GIO configuration |
Educational BoosterPack MKII and Hercules LaunchPad - LCD Driver part 3: PWM for the backlight |
Educational BoosterPack MKII and Hercules LaunchPad - LCD Driver part 4: Draw, Write and show Bitmaps |
Top Comments