- Industrial/automotive: My design provides a solution for display applications on Hercules safety microcontrollers.
- supports a large number of common LCD displays
- low memory footprint library
- uses 6 gio pins, configurable
- Tested with TMS and RM LaunchPad
- no other components required
How to use it:
I expect you already know how to work with HALCoGen and Code Composer Studio from following Project0 on the Hercules LaunchPad wiki.
- First, start HALCoGen and create a new project.
- Select your correct processor, and name the project LCD
- Go to the "Driver Enable" tab, and only select "GIO" and "HET".
- File -> Save Project File -> Generate Code
- Close HALCoGen
- Start CCSvX File -> -> New -> CCS project
- Project Name: LCD
- In Device, select your processor.
- In Project Templates, select "Empty Project" -> press Finish
- In the project explorer, right click on project "LCD" -> Properties select Build -> ARM Compiler -> Include Options
- In the box "Add dir to #include search path", click + button.
- Click Workspace
- Select LCD - include
- Press OK
- Press OK
- Press OK
- Download the 3 source files from GitHub. You can use the link in this project's attachments to get the full ZIP.
- Place
sys_main.c
and44780.c
in the source directory of your CCS LCD project.
- Place
44780.h
in the include directory.
- Do the same with the source and header file of the GioUtils folder that is in the same ZIP.
gioutils.c
in the source directory,gioutils.h
in the include directory.
- Compile.
The Launchpad code is now ready.
Hardware:Header layout of Launchpad: http://processors.wiki.ti.com/images/0/02/Hercules_LaunchPad_Header.pdf
LCD Shield schema: http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html
attention: if you follow this schematic, never drive D10
of the shield high. It can only have 0 or open. Driving it high would bias the basis-emitter junction of Q1
and you have a shortcut from your pin to ground. I haven't tried this, but expect that if you want to PWM the brightness, you'll have to define the output pin as open collector.
You can choose what pins to use, but if you use my system_main.c, you have to connect following pins:
- LCD DB4 -> LP J4:2 (NHET[2])
- LCD DB5 -> LP J4:3 (NHET[4])
- LCD DB6 -> LP J4:4 (NHET[6])
- LCD DB7 -> LP J4:5 (NHET[10])
- LCD RS -> LP J4:6 (NHET[12])
- LCD ENABLE -> LP J4:7 (NHET[14])
- LCD VSS -> LP J3:2 (GND)
- LCD ~RW -> LP J3:2 (GND)
- LCD VDD -> LP J3:1 (5V)
gioPin_t rs = {hetPORT1,12};
gioPin_t enable = {hetPORT1,14};
gioPin_t d0 = {hetPORT1,2};
gioPin_t d1 = {hetPORT1,4};
gioPin_t d2 = {hetPORT1,6};
gioPin_t d3 = {hetPORT1,10};
lcdInit(&rs, &enable, &d0, &d1, &d2, &d3);
lcdBegin(16,2, 0);
lcdSetCursor(0,0); // move to the beginning of the first line
lcdPrint("Hello, world!");
Check out the readme: https://github.com/jancumps/hercules_libraries/blob/master/README.md
Comments