Shared Project: LPC832 16x2 LCD driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Shared Project: LPC832 16x2 LCD driver

Jump to solution
2,242 Views
aaronm
Contributor IV

This isn't a request for help; I'm sharing work with the community in the hopes that it helps someone else in a similar scenario.  Free to use as you wish, and I take no responsibility for any issues you have with it.

I'm doing work with a µcontroller that doesn't have tons of pins to spare for an LCD, so I decided to use an LPC832 as a 16x2 LCD driver over SPI, to reduce the number of pins needed on my main controller.  I came up with this, and it seems to work pretty well, so I thought I'd share.  I tested it with Bus Master 5's SPI mode, and it responded appropriately, but you'll have to test it with your environment.

Untar the "tgz" file, import it into MCUXpresso as a new project, connect your pins as shown in the illustration, and it should work.  It uses "command" bytes to indicate what action you want to take:

0 = clear; sub-command 0 - entire screen; 1 - the current line
1 = goto; row col
2 = print; sub-command 0 - single character; 1 - string
3 = LCD display command; command bytes relevant to your LCD display
anything else is ignored

Commands and operands are separated by spaces, so "0 0" clears the entire screen.  "2 1 ascii bytes" prints a string at the current LCD position.  "1 1 0" goto row 1 (second row; counting from offset 0), position 0.

This is configured for 16x2, but it wouldn't be hard to adjust for bigger screens.

Thanks to @ErichStyger for his HD44780 library, on which this is partially based.

https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/HD44780/McuHD44780.c

Labels (1)
0 Kudos
Reply
1 Solution
2,222 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, thanks for your contribution on the community.

Best regards,
Pavel

View solution in original post

1 Reply
2,223 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, thanks for your contribution on the community.

Best regards,
Pavel

%3CLINGO-SUB%20id%3D%22lingo-sub-1997614%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EShared%20Project%3A%20LPC832%2016x2%20LCD%20driver%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1997614%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThis%20isn't%20a%20request%20for%20help%3B%20I'm%20sharing%20work%20with%20the%20community%20in%20the%20hopes%20that%20it%20helps%20someone%20else%20in%20a%20similar%20scenario.%20%26nbsp%3BFree%20to%20use%20as%20you%20wish%2C%20and%20I%20take%20no%20responsibility%20for%20any%20issues%20you%20have%20with%20it.%3C%2FP%3E%3CP%3EI'm%20doing%20work%20with%20a%20%C2%B5controller%20that%20doesn't%20have%20tons%20of%20pins%20to%20spare%20for%20an%20LCD%2C%20so%20I%20decided%20to%20use%20an%20LPC832%20as%20a%2016x2%20LCD%20driver%20over%20SPI%2C%20to%20reduce%20the%20number%20of%20pins%20needed%20on%20my%20main%20controller.%20%26nbsp%3BI%20came%20up%20with%20this%2C%20and%20it%20seems%20to%20work%20pretty%20well%2C%20so%20I%20thought%20I'd%20share.%20%26nbsp%3BI%20tested%20it%20with%20Bus%20Master%205's%20SPI%20mode%2C%20and%20it%20responded%20appropriately%2C%20but%20you'll%20have%20to%20test%20it%20with%20your%20environment.%3C%2FP%3E%3CP%3EUntar%20the%20%22tgz%22%20file%2C%20import%20it%20into%20MCUXpresso%20as%20a%20new%20project%2C%20connect%20your%20pins%20as%20shown%20in%20the%20illustration%2C%20and%20it%20should%20work.%20%26nbsp%3BIt%20uses%20%22command%22%20bytes%20to%20indicate%20what%20action%20you%20want%20to%20take%3A%3C%2FP%3E%3CPRE%3E0%20%3D%20clear%3B%20sub-command%200%20-%20entire%20screen%3B%201%20-%20the%20current%20line%3CBR%20%2F%3E1%20%3D%20goto%3B%20row%20col%3CBR%20%2F%3E2%20%3D%20print%3B%20sub-command%200%20-%20single%20character%3B%201%20-%20string%3CBR%20%2F%3E3%20%3D%20LCD%20display%20command%3B%20command%20bytes%20relevant%20to%20your%20LCD%20display%3CBR%20%2F%3Eanything%20else%20is%20ignored%3C%2FPRE%3E%3CP%3ECommands%20and%20operands%20are%20separated%20by%20spaces%2C%20so%20%220%200%22%20clears%20the%20entire%20screen.%20%26nbsp%3B%222%201%20ascii%20bytes%22%20prints%20a%20string%20at%20the%20current%20LCD%20position.%20%26nbsp%3B%221%201%200%22%20goto%20row%201%20(second%20row%3B%20counting%20from%20offset%200)%2C%20position%200.%3C%2FP%3E%3CP%3EThis%20is%20configured%20for%2016x2%2C%20but%20it%20wouldn't%20be%20hard%20to%20adjust%20for%20bigger%20screens.%3C%2FP%3E%3CP%3EThanks%20to%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F17173%22%20target%3D%22_blank%22%3E%40ErichStyger%3C%2FA%3E%26nbsp%3Bfor%20his%20HD44780%20library%2C%20on%20which%20this%20is%20partially%20based.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FErichStyger%2FMcuOnEclipseLibrary%2Fblob%2Fmaster%2Flib%2FHD44780%2FMcuHD44780.c%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FErichStyger%2FMcuOnEclipseLibrary%2Fblob%2Fmaster%2Flib%2FHD44780%2FMcuHD44780.c%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1997614%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ELPC800%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1998373%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Shared%20Project%3A%20LPC832%2016x2%20LCD%20driver%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1998373%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%20thanks%20for%20your%20contribution%20on%20the%20community.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E