MSP430 LiquidCrystal Library

3902 views
Skip to first unread message

♌ pez ♌

unread,
Nov 26, 2010, 7:53:22 PM11/26/10
to hive76-d...@googlegroups.com
Here's a port of the most basic functions from the Arduino LiquidCrystal library to MSP430.  The library is defined in HD44780Lib.h

The project also includes a port of some of the most basic Wiring functions, since it made the job of porting the LiquidCrystal library simpler.  These "arduino-ish" functions are in the "Wiring.h" file.

The testHD44780.c file is a simple "hello world" kind of example.

The attached picture shows how to hook things up, if you're inclined to give it a try.  It should work with any HD44780 display.

One problem -- the library is a pig, so I'll need to optimize it a little if want to host it on an MSP430G2001



Launchpad_HD44780.jpg
HD44780Lib.h
testHD44780.c
Wiring.h

♌ pez ♌

unread,
Nov 26, 2010, 8:03:09 PM11/26/10
to hive76-d...@googlegroups.com
oops, many crossed wires in the original diagram ...
Launchpad_HD44780.jpg

pezman

unread,
Nov 26, 2010, 8:30:14 PM11/26/10
to Hive76 Discussion
http://www.youtube.com/watch?v=ecyFEQc1MMk

On Nov 26, 8:03 pm, "♌ pez ♌" <mikehoga...@gmail.com> wrote:
> oops, many crossed wires in the original diagram ...
>
> On Fri, Nov 26, 2010 at 7:53 PM, ♌ pez ♌ <mikehoga...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Here's a port of the most basic functions from the Arduino LiquidCrystal
> > library to MSP430.  The library is defined in HD44780Lib.h
>
> > The project also includes a port of some of the most basic Wiring
> > functions, since it made the job of porting the LiquidCrystal library
> > simpler.  These "arduino-ish" functions are in the "Wiring.h" file.
>
> > The testHD44780.c file is a simple "hello world" kind of example.
>
> > The attached picture shows how to hook things up, if you're inclined to
> > give it a try.  It should work with any HD44780 display.
>
> > One problem -- the library is a pig, so I'll need to optimize it a little
> > if want to host it on an MSP430G2001
>
>
>
>  Launchpad_HD44780.jpg
> 68KViewDownload

Tom

unread,
Dec 30, 2010, 12:10:17 PM12/30/10
to Hive76 Discussion
Nice work but... unless you're using USB to supply power, it's
annoying that you need a 5V line isn't it? I understand that 3.3V LCD
panels are a bit harder to get hold of though...

On Nov 27, 1:30 am, pezman <mikehoga...@gmail.com> wrote:
> http://www.youtube.com/watch?v=ecyFEQc1MMk
>
> On Nov 26, 8:03 pm, "♌ pez ♌" <mikehoga...@gmail.com> wrote:
>
>
>
>
>
>
>
> > oops, many crossedwires in the original diagram ...

pezman

unread,
Dec 30, 2010, 12:27:03 PM12/30/10
to Hive76 Discussion
Agreed -- I stole the 5v off one of the test-points on the LaunchPad
(near the USB connector).

The signal levels on the MSP work fine for 5v displays (at least when
the chip is at 3.6 volts).

One "pure" option might be to use one of the spare GPIOs as a digital
oscillator that that feeds a little charge pump. Should work for
displays w/o backlighting.

Bob430

unread,
Jan 14, 2011, 7:04:15 PM1/14/11
to Hive76 Discussion
I'm having trouble getting this to work. Does your diagram use the
same pinout as listed here : http://en.wikipedia.org/wiki/HD44780_Character_LCD
?

Thanks.

Bob430

unread,
Jan 15, 2011, 9:09:32 PM1/15/11
to Hive76 Discussion
I got it working, I had to connect the contrast pin. How do I write to
the second line?
Thanks.

pezman

unread,
Jan 15, 2011, 9:24:05 PM1/15/11
to Hive76 Discussion
I believe there's a command for that. I'd check the LiquidCrystal
library for Arduino for an example. If a suitably adapted example for
the MSP430 doesn't work, i'll dig in and try to fix it.

That's the beauty (and curse) of the approach -- I didn't really think
about the interface .. just thought about how to port it w/ minimal
fuss.

pezman

unread,
Jan 15, 2011, 11:54:58 PM1/15/11
to Hive76 Discussion
Hmm, looks like I need to add "setCursor". Here's the Arduino code

void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row > _numlines ) {
row = _numlines-1; // we count rows starting w/0
}

command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}

The MSP430 version ought to look something like:

void HD44780_setCursor(HD44780 *me, uint8_t col, uint8_t row)) {
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row > me->_numlines ) {
row = me->_numlines-1; // we count rows starting w/0
}

HD44780_command(me, LCD_SETDDRAMADDR | (col + row_offsets[row]));
}

Anyone want to try it (and debug) before I do?

Bob430

unread,
Jan 16, 2011, 10:12:08 AM1/16/11
to Hive76 Discussion
Your setCursor code works flawlessly.

Could you point me towards the Arduino source code for the library? I
only just started learning the MSP430, but I would like to try to
implement the display scrolling methods.

Many thanks for the code and your help.

pezman

unread,
Jan 16, 2011, 12:52:06 PM1/16/11
to Hive76 Discussion
Hi Bob,

The Arduino LiquidCrystal documentation is here:
http://www.arduino.cc/en/Reference/LiquidCrystal

I think that the code is installed with the Arduino software, which
you can get here:
http://arduino.cc/en/Main/Software

The library will be under the installation folder. For example, on my
laptop's Windows boot, it's here:
C:\Users\mike\Desktop\arduino-0018\libraries\LiquidCrystal

Many of the methods are inline functions (found in LiquidCrystal.h,
and can be adapted by following the pattern that was used to create
the setCursor method above.

I should probably set up a Bzr account so that improvements can be
published ...

Bob430

unread,
Jan 16, 2011, 4:18:12 PM1/16/11
to Hive76 Discussion
Thanks a lot for that.

Here are the two scrolling methods:

void HD44780_scrollDisplayLeft(HD44780 *me){
HD44780_command(me, LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}

void HD44780_scrollDisplayRight(HD44780 *me){
HD44780_command(me, LCD_CURSORSHIFT | LCD_DISPLAYMOVE |
LCD_MOVERIGHT);

pezman

unread,
Jan 16, 2011, 8:52:36 PM1/16/11
to Hive76 Discussion
Nice
Reply all
Reply to author
Forward
0 new messages