I have been toying with a “TI Launchpad” recently, something I’ve been trying is to get it to work with the popular HD44780 LCD.
The LCD supports loading of custom characters in addition to the standard character set – with Arduino this seems very easily done.
However the Launchpad, based on the msp430 chip from TI is still relatively new – so not a lot exists at the moment for setting up with Launchpad and getting custom characters loaded.
Thankfully there is already a large example out that has the basics of the LCD done. What was wrong from that basic setup was the ability to work with the newer msp430-gcc (uniarch) compiler – from here. I moved to this some time ago to use the full benefits of the msp430g2553 chip – it is the more beefier chip that is a drop in replacement for the included chip (also features onboard UART, great for serial comms).
The basics needed changing, “Wiring.h” had to be edited to be compatible with the new compiler, the pin out was different (the schematic at the URL above was missing contrast).
The changes made to Wiring.h are:
//#pragma vector = TIMERA0_VECTORÂ Â Â Â
interrupt(TIMER0_A0_VECTOR) Â TA0_ISR (void)Â Â Â Â {Â Â Â Â
//    __low_power_mode_off_on_exit(); // Restore Active Mode on return   Â
}
The low power mode is commented out – I won’t need to use it for the chip is low power to begin with and will be connected to mains via USB – but it’s very easy to modify the SR register to take out sleep mode.
#include <stdbool.h>
#include <stdio.h>
#include <msp430.h>
#include <legacymsp430.h>
#include <stdint.h>
#include <msp430g2553.h>// Headers for specific device#
include "HD44780LIB.h"
To design a character, there’s a handy webpage here that explains the bits that need to be written to the display (8 possible custom characters). I wanted numbers and after having the MPGuino code handy from my ongoing project for the car – I simply converted those bits to hex and used them:
unsigned char chars[] = { 0x1F,0x1F,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x1F,0x1F,
0x1F,0x1F,0x0,0x0,0x0,0x0,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0xF,0x7,
0x0,0x0,0x0,0x0,0x0,0xE,0xE,0xE,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1E,0x1C,
0x7,0xF,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1C,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F };
The characters are rounded characters, they look good on the display. To load the characters, use the command and write functions as below:
HD44780_init(&theHD44780,4,3,0,5,2,1);Â Â Â Â //this is different, I copied the Wiring functions to use P2 (Port 2).
HD44780_begin(&theHD44780,16, 2);Â Â Â Â
HD44780_print_string(&theHD44780, "Hello");Â Â Â Â
HD44780_pulseEnable(&theHD44780);Â Â Â Â
HD44780_command(&theHD44780, 0x48);Â
for (i = 0; i<64; i++) {
        HD44780_write(&theHD44780,chars[i]);
 }
HD44780_pulseEnable(&theHD44780); Â Â Â Â Â Â Â Â
HD44780_command(&theHD44780, 0x01);Â Â Â Â
HD44780_pulseEnable(&theHD44780);Â Â Â Â
HD44780_command(&theHD44780, 0x80);Â Â Â Â
HD44780_gotoXY(&theHD44780, 0, 0);
The init line differs because I changed the pin outs so I could use the UART on the chip (P1.1 and P1.2). I also had issues with the display not loading properly so I moved all to Port 2 and all seems well now. In the above, I also used 0x48 as the CGRAM command – it’s noted in the original as being 0x40, the 0x48 request worked – I sticked with what worked.
The gotoXY function I added t HD44780LIB.h, it is below, but is sourced from MPGuino – it’s a simple function:
void HD44780_gotoXY(HD44780 *me, unsigned int x, unsigned int y) {
        unsigned int dr=x+0x80;
        if (y==1) dr += 0x40;
        if (y==2) dr += 0x14;
        if (y==3) dr += 0x54;
        HD44780_command(me, dr);   Â
}
Accessing the characters is easy enough – HD44780_print_byte(&theHD44780, 2) would display character 2 from the CGRAM (which, if we start from 0 is the third character in CGRAM).
The end result being targetted is adding this LCD to the system I have in the lounge room, it has a backlight, so I’ll display the clock and a few other things that aren’t easily seen with just the TV on. I’ll cut an opening for it in a cover in the 5.25″ bay, and glue some stand off screws to hold the display upright and bury the MCU down the bottom, and tap USB from the Motherboard directly.
I’ll be adding some other functions to it as well – Now Playing comes to mind for streaming music.
There is already an LCD project that exists for Linux completely negating the need for the MCU in the middle – it’s here – but I already had the LCD rigged up to the Launchpad when I decided to start it – so I’ll stick with it.
Pingback: Loading Custom Characters into HD44780 LCD display | TOCPCs – The … | Electronics Blog
Pingback: BELKIN LCD Display Cleaner F8E404 | New HDTV Store