Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

16x2 I2C LCD connected to MSP432 - only displaying some characters

Other Parts Discussed in Thread: ENERGIA

Hello,

 

I'm writing a program for interfacing a 1602 LCD (equipped with I2C backpack, works in Energia) to MSP42 with the use of I2C protocol. I'm not writing my own routines, so I decided to go with DriverLib ones in CCS. LCD successfully initializes (powered, cursor blinking and ready to go) and after I try with different combinations of signals to get different characters, only some seem to appear. 

I initialize the LCD to 4 bit mode with the code below:

void lcdInit(void){

	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x30);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x30);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x30);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x20);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x28);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x08);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x01);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x06);
	__delay_cycles(10000);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x0C);

}

After it exectues, the LCD is lit on and the cursor blinks. Now, in 4 bit operation we have to send data in 2 chunks. Each chunk is 6 bits, 4 data + 2 for RS and RW. 

Going by the LCD reference (http://www.tme.eu/en...02b-biw-esx.pdf), I thought I could write a character "A" with two successive commands, like:

	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x9);
	I2C_masterSendSingleByte(EUSCI_B0_MODULE, 0x21);

// 0x9  = 0b001001 // last 2 bits are RW and RS
// 0x21 = 0b100001 //

However, nothing usually happens, and if I'm lucky with the combinations, the characters from last row (LCD reference, page 11) are printed (?, /, O, _, ..) and no others. 

I can't seem to figure out what is going on exactly to try to get a pattern of errors being made. I'm almost sure I'm sending the wrong commands and not bit shifting properly. I also suspect I'm somehow sending the bits in the wrong order or shifted, because SendSingleByte adds two 0's in front of the desired 6 bit sequence. And ideas?

 

Thanks!

  • Hi Jimmy!

    Could you link in some information to your I²C backpack? Or is it just a I²C to parallel out converter? If so, which one? Do you have a schematic?

    Dennis
  • I believe that you have to wait for the I2C master to finish the transaction (with a delay) before sending the next transaction.

    If both bytes are supposed to be sent in the same I2C transaction, then you need to look at the I2C_masterSendMultiByteXxxx functions.
  • Thanks for the suggestions. 

    I solved the problem, it works correctly now. The cause of incorrect operation was bad initialization of the LCD. Raystar 1602's have slightly different init sequences than the standard Hitachi HD I guess.

    Anyways, if it helps somebody else, here's the initialization command order for 4 bit operation for Raystar RC1602B (PCF8574T I2C backpack) which works for me:

        sendCommand(0x30);
        sendCommand(0x40);
        sendCommand(0x34);
        sendCommand(0x40);
        sendCommand(0x34);
        sendCommand(0x0);
        sendCommand(0x3C);
        sendCommand(0x0); 
        sendCommand(0x20);
        sendCommand(0x0); 
        sendCommand(0x38);

    Commands and data are sent with SendByte DriverLib routine mentioned above.

**Attention** This is a public forum