Jump to content
Sign in to follow this  
Blairo

Connecting MSP432 to 1602 LCD via I2C

Recommended Posts

Hello,

 

I'm trying to get a standard 1602 LCD (16x2 from Raystar) connected to MSP432 with the I2C interface. Are there any existing libraries which could help me out? I've found some I2C libraries for Arduino but naturally they're not compatible, and the only existing Energia examples deal with CogLCD which uses a SPI interface (emerging question: is there a way to make SPI and I2C compatible?) or standard 16 pin connection. MSP432 is still a relatively fresh chip, so I can't find any examples whatsoever.

 

Thanks!

 

 

Share this post


Link to post
Share on other sites

I tried the examples using Arduino's Liquid Crystal I2C library (LiquidCrystal_i2C.h) but that doesn't seem to work in energia, will not compile at all.

Share this post


Link to post
Share on other sites

Hello @@Blairo

 

A while back I made a 43oh post with Energia examples here:  http://forum.43oh.com/topic/8766-sensor-code-examples/

 

Follow the github link to find them.  The one named I2C_LCD has been tested on the MSP432 and should work for you.  However, you will need to do the following:

  • Make sure you do level conversion - the LCDs are usually 5V devices
  • The example is for the F5529.  For the MSP432 you need to connect SCL and SDA to pins 9 and 10 respectively.  There is a footnote to this effect in the code
  • The example is for a 4x20 LCD.  If you are using a 2x16 you need to change the variables rows and columns to 2 and 16 respectively.
  • Make sure I2C address is correct for your LCD.

Let me know if it works....

Share this post


Link to post
Share on other sites

It works! I did a level conversion for SDA and SCL while using 5 volts for power. Thanks a lot, now I only need to make this work in my CCS project. Seeing this uses some energia libraries, would I do this just by including the appropriate Energia headers in my CCS project?

 

Update: Okay, so I naively tried to include the necessary header files (like print.h, wire.h, ...) into my CCS project in order to try and make the LCD code compile, but it doesn't seem to work that way since I get all kinds of errors. Any ideas?

 

Thanks.

Share this post


Link to post
Share on other sites

Thanks, will take a look at it. What I noticed though was that CSS doesn't yet support importing MSP432 Energia sketches. I tried importing a blink example, but there's no MSP432 on the available device list and choosing anything else gives me an error when uploading ("No USB FET was found").

 

For clarification: I don't just want to import Energia sketch into CCS, because then I'm just changing IDE's. What I want to do is to find a way to make a main.c file which includes LiquidCrystal_I2C.h and can make an LCD work, since my project, which needs the LCD functionality, is already written in CCS.

Share this post


Link to post
Share on other sites

Hello,

 

I am having trouble getting my LCD with interface to work with my MSP432 microcontroller. I have followed all the instructions you have here and the code compiled and uploaded just fine. But nothing shows up on the display. I'm not sure why you suggest the first step to level up the voltage as there is a 5V pin on the MSP432 which I am using. Do you have any ideas on how I can troubleshoot the problem? Here is the code I am using:

 

#include <Wire.h> 
#include "LiquidCrystal_I2C.h"
 
byte address = 0x64;      // LCD I2C address
int columns = 16;         // number of columns on LCD
int rows = 2;             // number of rows on LCD
LiquidCrystal_I2C lcd(address, columns, rows);  
 
// make custom characters:
byte rocket[8] = {
  0b00000,
  0b00000,
  0b00100,
  0b01110,
  0b01110,
  0b01110,
  0b11111,
  0b11111
};
byte liftOff[8] = {
  0b00100,
  0b01110,
  0b01110,
  0b01110,
  0b11111,
  0b11111,
  0b01010,
  0b00100
};
 
void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
 
  lcd.createChar(0, rocket);       // Create Character 0
  lcd.createChar(1, liftOff);      // Create Character 1
}
 
void loop()
{  
  // Clear everything
  lcd.clear();
  
  // Place Energia in first column, first row
  lcd.setCursor(0,0);
  lcd.print("Energia");
  
  // Place rocket ready for launch at right, bottom
  lcd.setCursor(14, (rows-1));
  lcd.write(0);
  
  // Countdown
  for (int i = 10; i > -1; i--)
  {
    lcd.setCursor(8,0);
    lcd.print(i);
    delay(1000);
    lcd.setCursor(8,0);
    lcd.print("  ");
  }
 
  // Liftoff 
  for (int i = (rows-1); i > -1; i--)
  {
    lcd.setCursor(14, i);
    lcd.write(1);
    delay(1000);
    lcd.setCursor(14, i);
    lcd.print(" ");
  }
  
  delay(2000); 
}
 
Thank you for any help you can provide!!!

Share this post


Link to post
Share on other sites

When connecting devices together that use different supply voltages you will often need to level shift on the data lines. The lauchpad and the display have different thresholds for what consitutes a high or low signal. You may want to google 'voltage level shifting' for some more information on the subject. I believe that sparkfun.com has a variety of breadboard friendly level shifters.

Share this post


Link to post
Share on other sites

Also having trouble making an MSP432 communicate with an LCD screen, have tried many things to no avail. Here's some info:

 

  • Launchpad MSP432P401R Rev 1.0
  • Using Energia 0101E0017 on Windows 7 64-bit
  • LCD Screen is a SpikenzieLabs w/ interface (LCDINTERFACE) (uses the common HD44780 chipset)

I'm trying to implement simple code to reduce the complexity of troubleshooting, here's the code I'm using:

 

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x20,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
 
void setup()
{
 
lcd.init();                      // initialize the lcd 
 // Print a message to the LCD.
 lcd.backlight();
 lcd.print("Hello, world!");
 
}
 
void loop()
{
}

 

I've provided a picture of my set up and results after uploading the code one time: 

 

http://imgur.com/HbwLOt0

 

My thoughts:

 

After every iteration of uploading the code, the screen outputs one iteration of: 040040040 $  $ 

I've tried many different I2C addresses that I have seen suggested throughout the forums, and tried running an I2CScan program to find the actual address (couldn't make I2CScan work on the 432). The only result I get, as seen above, is with an address of 0x20. My interpretation of the resulting output to the LCD screen is this: I2C addresses are 7-bit, plus an 8th bit to indicate read or write status. The 8th bit is added as the LSB of the address. After a 0 (for write) is added to the address 0x20, the result is 0x40. Is this why the screen is displaying 040? Or am I wrong in thinking this?

 

Can someone tell me what is wrong, or if I am doing something wrong here? Any help is appreciated greatly!

 

(Does this come down to stepping up the voltage of the data pins as stated above?)

Share this post


Link to post
Share on other sites

Update: I took the advice of level shifting the SDA and SCL data lines. I constructed the MOSFET circuit that was recommended by Rei Vilo's link above, the output to my LCD screen remained the same. I've double and triple checked my mosfet circuit and it seems correct. 

 

Still stuck. Unfortunately this is a time sensitive issue, and any help is greatly appreciated. Thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...