4bit LCD interface

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

4bit LCD interface

2,419件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Sun Nov 28 14:15:45 MST 2010
Hi, I am trying to drive a 16x2 LCD only with 4 data pins but unfortunately with no success. Im using lpcexpresso  with lpc1343 and HD44780 based lcd. I'm open to suggestions
here is my code:
include "LPC13xx.h"
#include "gpio.h"

#define LCD_MAX_COL 16
#define LCD_MAX_ROW 2
#define LCD_BASEADDR0x8000
#define LCD_DELAY 500
#define LED_ONGPIOSetValue(0,7,1)
#define LED_OFFGPIOSetValue(0,7,0)
#define LCD_ENABLE()GPIOSetValue(2,8,1) //Port P2.8 = 1
#define LCD_DISABLE()GPIOSetValue(2,8,0) //Port P2.8 = 0
#define LCD_RWON() GPIOSetValue(2,9,1) //Port P2.9 = 1
#define LCD_RWOFF() GPIOSetValue(2,9,0) //Port P2.9 = 0
#define LCD_RSON() GPIOSetValue(2,10,1) //Port P2.10 = 1
#define LCD_RSOFF() GPIOSetValue(2,10,0) //Port P2.10 = 0
#define LCD_DATA(Data)LPC_GPIO[2]->MASKED_ACCESS[(0x00FF)] = Data //P2.0-7 = Data
#define LCD_SET_SYSTEM 0x20 //
#define LCD_SYS_8BIT 0x10 //
#define LCD_SYS_2LINE 0x08 //
#define LCD_DOT_5_11 0x04
#define LCD_SET_DISPLAY 0x08 //
#define LCD_DISP_DISPLAY_ON 0x04 //
#define LCD_CURSOR_HOME 0x02
#define LCD_CLEAR 0x01
//Function prototype
char lcd_ready(void); // Check for LCD to be ready
char lcd_init(void); // LCD Init
void lcd_gotoxy(uint8_t x, uint8_t y);// Output character string in current Cursor.
char* lcd_puts(uint8_t* str); // Output character stream in current Cursor.
void evb_set_lcd_text(uint8_t row, uint8_t* lcd);
void lcd_busy(void);
void lcd_command(uint8_t Value);
void Delay (uint32_t dlyTicks);
volatile uint32_t msTicks; // counts 1ms timeTicks
//*******************************************
// system stick interrupt handler
void SysTick_Handler(void) {
msTicks++; // increment counter necessary in Delay()
}
//*******************************************
// delays number of tick Systicks (happens every 1 ms)
void Delay (uint32_t dlyTicks) {
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}
//*******************************************
void write_byte (uint8_t Value)
{
uint8_t upperNibble = Value >> 4;
uint8_t lowerNibble = Value & 0x0F;

LCD_DATA(upperNibble);
LCD_DISABLE();
Delay(1);
LCD_ENABLE();
Delay(1);
LCD_DISABLE();
Delay(1);

LCD_DATA(lowerNibble);
LCD_DISABLE();
Delay(1);
LCD_ENABLE();
Delay(1);
LCD_DISABLE();
Delay(1);

}


void lcd_command(uint8_t cmd)
{

LCD_RSOFF();
Delay(3);
write_byte(cmd);
Delay(3);
}
//*******************************************
void lcd_data(uint8_t ch)
{

LCD_RSON();
Delay(3);
write_byte(ch);
Delay(3);
}
//*******************************************
char lcd_init(void)
{LCD_RWOFF();

//LCD_DISABLE();
//LCD_RSOFF();
Delay(20);

write_byte(0x30);
Delay(10);
write_byte(0x30);
Delay(5);
write_byte(0x30);
Delay(5);
write_byte(0x20);
Delay(5);

lcd_command(0x28);
Delay(100);
lcd_command(0x0C);
Delay(100);
lcd_command(0x08);
Delay(100);
lcd_command(LCD_CLEAR);
Delay(100);
lcd_command(LCD_CURSOR_HOME);
return 1;
}
//*******************************************
void lcd_gotoxy( uint8_t x, uint8_t y )
{
switch(y)
{
case 0 : lcd_command(0x80 + x); break;
case 1 : lcd_command(0xC0 + x); break;
case 2 : lcd_command(0x94 + x); break;
case 3 : lcd_command(0xD4 + x); break;
}
}
//*******************************************
char * lcd_puts(uint8_t * str)
{
uint8_t i;
for (i=0; str != '\0'; i++){
// wait_1ms(4);
lcd_data(str);
}
return str;
}
//*******************************************
void evb_set_lcd_text(uint8_t row, uint8_t * lcd)
{
lcd_gotoxy(0,row);
lcd_puts((char*)lcd);
}
//*********************************************
// Main Program

int main (void)
{

GPIOInit();
LPC_GPIO[2]->DIR = 0b011111111111;
GPIOSetDir( 0, 7, 1 );
LED_OFF;
LCD_RWOFF();
if (SysTick_Config(SystemCoreClock / 1000)) {
while (1);
}
if ( !(SysTick->CTRL & SysTick_CTRL_CLKSOURCE_Msk) )
{LPC_SYSCON->SYSTICKCLKDIV = 0x08;}

LED_ON;
lcd_init();
LED_OFF;
lcd_command(LCD_CLEAR);
evb_set_lcd_text(1,"abcdef");
lcd_gotoxy(4,1);
lcd_puts("abc123");

}
0 件の賞賛
返信
14 返答(返信)

2,198件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Mar 02 04:09:44 MST 2015

Quote: dandumit
I have tried to search as well all threads for words LCD and LCD + jharwood but no relevant answers.



:quest:

Search 'jharwood + lcd.zip'

to find

http://www.lpcware.com/content/forum/using-pca8574-with-i2c

with lcd.zip  :)

BTW: lcd.zip is attached above already...
0 件の賞賛
返信

2,198件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dandumit on Mon Mar 02 03:34:28 MST 2015

Quote: serge

This comes from a previous thread on this forum:eek:. http://knowledgebase.nxp.com/showthread.php?t=1753

So please read the sticky note at the beginning of the forum and do a search first before starting a new thread :D your question may have been answered previously.



Hi, that link it's not working.  I have tried to search as well all threads for words LCD and LCD + jharwood but no relevant answers.

Could you please point to original post ?

Daniel
0 件の賞賛
返信

2,198件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mali_Matek on Fri Jul 13 02:37:15 MST 2012
Tnx,

I read the sticky note at the beginning of the forum, but use bad keywords for  search and found only this thread :)
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Fri Jul 13 00:22:52 MST 2012
Take a look at this: [ATTACH]802[/ATTACH]
You need CMSISv1p30_LPC13xx in your project (or you could change it to use CMSISv2)
With many thanks to jharwood.:p
This comes from a previous thread on this forum:eek:. http://knowledgebase.nxp.com/showthread.php?t=1753

So please read the sticky note at the beginning of the forum and do a search first before starting a new thread :D your question may have been answered previously.
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mali_Matek on Thu Jul 12 13:20:59 MST 2012
Hi,
Did anyone have correct code for display, I modify code from first post, but I get only few lines (no symbols) on display?

Tnx

P.S. if I miss the thread where is the correct code sorry for spam.
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by A7_ on Fri Apr 22 08:56:39 MST 2011
thanks man!

my code is very similar to yours, same commands, same algorithm, the only difference is the delay functions, i'm using the delay32Ms() function that comes in an example library.. (timer32.h) maybe that's the problem.. =S
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Thu Apr 21 23:11:42 MST 2011
Maybe this comes in handy:

Driver:
http://repo.or.cz/w/cbaos.git/blob/HEAD:/drivers/misc/hd44780.c

Example usage:
http://repo.or.cz/w/cbaos.git/blob/HEAD:/test/test_hd44780.c

Shouldn't be too hard to adapt
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by A7_ on Thu Apr 21 21:11:54 MST 2011
Hi,

Just got one lpc1114 board this week, and i'm heving trouble interfacing it with the char lcd.. i can get chars on screen, but not the ones i sent. Also, they're looping on the screen - in a very cool visual effect, but not very useful =D - Can you post your working code? i don't know if i'm using the right commands, or timings..

thanks a lot
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Tue Feb 15 05:23:34 MST 2011
I have never seen this kind of controller, are you sure it isn't HD44780?
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Tue Feb 15 04:24:34 MST 2011
Can you drive 4 bit Hitachi HD780 with this source code?
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Fri Jan 07 13:45:16 MST 2011
actually I've found a solution. It was all in the initialization
void LCD_Init()
{
//
// Set up the I/O ports that the LCD module is connected to
//
GPIOSetDir(LCD_PORT_E,  LCD_BIT_E,  PORT_DIR_OUTPUT);
GPIOSetDir(LCD_PORT_RS, LCD_BIT_RS, PORT_DIR_OUTPUT);
GPIOSetDir(LCD_PORT_D4, LCD_BIT_D4, PORT_DIR_OUTPUT);
GPIOSetDir(LCD_PORT_D5, LCD_BIT_D5, PORT_DIR_OUTPUT);
GPIOSetDir(LCD_PORT_D6, LCD_BIT_D6, PORT_DIR_OUTPUT);
GPIOSetDir(LCD_PORT_D7, LCD_BIT_D7, PORT_DIR_OUTPUT);

//
// Configure the LCD module for 4 bit input
//
LCD_WriteByte(0x33, LCD_COMMAND);// Reset the module
LCD_WriteByte(0x32, LCD_COMMAND);// Reset the module
LCD_WriteByte(0x2C, LCD_COMMAND);// Set 2 lines, small font, 4 bit mode
LCD_WriteByte(0x06, LCD_COMMAND);// Set it to "Cursor move" mode
LCD_WriteByte(0x0C, LCD_COMMAND);// Turn display on, turn cursor off
LCD_WriteByte(0x02, LCD_COMMAND);// Return cursor to "Home"
LCD_WriteByte(0x01, LCD_COMMAND);// Clear the display
LCD_WriteByte(0x80, LCD_COMMAND);// Set display to first line
}
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kendwyer on Thu Jan 06 16:30:00 MST 2011
Hi,

IAR actually use the same LCD on their LPC1300 Kickstart boards and have working examples in their tools installation directory: C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\examples\NXP\LPC13xx\IAR-LPC-1343-SK\GettingStarted\modules

Good luck!
Ken
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zzz on Thu Jan 06 13:55:11 MST 2011
Any luck on the LCD interface library?
0 件の賞賛
返信

2,197件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Tue Nov 30 07:42:19 MST 2010
Second day with no success, apparently i am too new to the lpcxpresso environment
and things still elude me. Can someone please send me a lcd library driver i can use? i'll be grateful for life :)
0 件の賞賛
返信