SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By ic3man5
#134572
I'm trying to initialize this (http://www.sparkfun.com/products/9052) display in 4-bit mode.

Has anybody gotten this display working, and if so was there anything in the datasheet that wasn't 100% documented for init?

Here is what I have now: http://www.youtube.com/watch?v=QEqqdGL_X0k
I'm holding reset on power to prevent initialization, resetting runs the init function over.

I've noticed in the 4-Bit init drawing the function set N and F bits are not in the correct position (Function set description and 8-bit init have them in B2 and B3 while the 4-bit has them in B0 and B1).

Here is how I'm initializing:

1.) Wait 30ms
2.) Set pins to 0011
3.) toggle E
4.) Wait 5ms
5.) toggle E
6.) Wait 200us
7.) toggle E
8.) Wait 200us // I'm not sure if this is needed
9.) toggle E
/* All writes below check busy flag before toggling e */
10.) 0010 1000 // Function set ---- according to init table this should be 00100010?
11.) 0000 1000 // Display off
12.) 0000 0001 // Clear
13.) 0000 0110 // Entry Mode, Increment enabled
/* Display should be initialized now */
14.) 0000 1110 // Display on, cursor enabled

I'm driving it from the msp430 launchpad and VCC is 3.5V
By ic3man5
#134638
I fixed one problem, P1.3 has a switch with a pull-up resistor and a cap to ground which was causing issues with bit 3. Also it looks like the initialization table for 4-bit is wrong for the first function set, follow the table description instead. Every time I use whats in the table I get blinking w/ cursor regardless of setting it after initialization.

Now my only problem is my function to display a character always outputs a capital O.

Edit: It only outputs a capital O when the function set N F bits are in position 0 and 1. Leaving them at Position 2 and 3 (Like the function set description says) makes writing to DDRAM messed up. Some character values do nothing while others increment the cursor to a position on the screen (And having the DDRAM address not match the cursor position). I'm not really sure why this is and I'm too tired tonight to debug it. Here is my write character function:
Code: Select all
/* Second parameter in lcd_write toggles rs pin high or low */
/* LCD_DDRAM = (1 << 7) */
/* lcd_write() sends bytes over in two segments for 4-bit mode, toggling e twice */
void lcd_put_char(char c)
{
	char address = lcd_read(0) & 0xC0;
	lcd_write(address | LCD_DDRAM, 0); /* This moves the cursor around correctly, address isn't always correct depending on last lcd_write(c, 1);
	lcd_write(c, 1);
}