4-bit LCD

A

abhay1581

Guest
Ciao amici.
Sono l'interfaccia LCD con n 89S8252 sto usando che LCD a 4 bit.
qualcuno può dirmi il codice esatto di inizializzazione per LCD? [/ b]

 
Per un codice di inizializzazione della voce è importante conoscere il tipo LCD esatta controller.

 
Qui è di routine init per LCD a 4 bit e utilizzo di PIC.Compilatore è CCS

/ / Lcd_lib_4bit.c
# include <stddef.h>

# define LCD_RS PIN_D2
/ / # define LCD_RW PIN_A1
# define LCD_EN PIN_D3

# define PIN_D4 LCD_D4
# define LCD_D5 PIN_D5
# define LCD_D6 PIN_D6
# define LCD_D7 PIN_D7

/ / Display misc definisce -
# define 0x80 Line_1
# define 0xC0 Line_2
# define Clear_Scr 0x01

/ / Istruzioni prototipo
# separati void LCD_Init (void); / / prosciutto Khoi Tao LCD
# LCD_SetPosition void separati (unsigned int cX); / / giro Thiet vi tri con tro
# separati void LCD_PutChar (unsigned int cX); / / len viet1kitu/1chuoi Ham LCD
# separati void LCD_PutCmd (unsigned int cX); / / GUI len Ham lenh LCD
# separati void LCD_PulseEnable (void); / / Xung hOAT KICH
# separati void LCD_SetData (unsigned int cX); / / Dat chan len du lieu dati
/ / D / Cong n
# usa standard_io (B)
# usa standard_io (A)

/ / Khoi Tao LCD ********************************************* *
# separati void LCD_Init (void)
(
LCD_SetData (0x00);
delay_ms (200);
output_low (LCD_RS); / / modalità di comando
LCD_SetData (0x03); / /
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_SetData (0x02);
LCD_PulseEnable ();
LCD_PutCmd (0x2C);
LCD_PutCmd (0b00001100);
LCD_PutCmd (0x06);
LCD_PutCmd (0x01);
)

# LCD_SetPosition void separati (unsigned int cX)
(
/ * Questa subroutine opere appositamente per 4-bit Port A * /
LCD_SetData (swap (CX) | 0x08);
LCD_PulseEnable ();
LCD_SetData (swap (CX));
LCD_PulseEnable ();
)

# separati void LCD_PutChar (unsigned int cX)
(
/ * Questa subroutine opere appositamente per 4-bit Port A * /
output_high (LCD_RS);
LCD_PutCmd (CX);
output_low (LCD_RS);
)

# separati void LCD_PutCmd (unsigned int cX)
(
/ * Questa subroutine opere appositamente per 4-bit Port A * /
LCD_SetData (swap (CX)); / * invia nibble alto * /
LCD_PulseEnable ();
LCD_SetData (swap (CX)); / * invia nibble basso * /
LCD_PulseEnable ();
)
# separati void LCD_PulseEnable (void)
(
output_high (LCD_EN);
delay_us (3); / / è stato di 10
output_low (LCD_EN);
delay_ms (3); / / è stato di 5
)

# separati void LCD_SetData (unsigned int cX)
(
output_bit (LCD_D4, cX & 0x01);
output_bit (LCD_D5, cX & 0x02);
output_bit (LCD_D6, cX & 0x04);
output_bit (LCD_D7, cX & 0x08);
)

GFT dal Vietnam
www.dientuvietnam.netAggiunto dopo 5 minuti:per AT89 e AVR è la stessa routine

 
se imparare in modo veloce u può utilizzare

per pic
http://www.mikroe.com/per 8051 core
http://www.mcselec.comper la simulazione
http://www.labcenter.co.uk/index_uk.htmNon ha bisogno di strumenti per il laboratorio di ur.

grazie

Masud

 
Si veda anche questo, io uso SDCC il libero C Compiler e p89v51

http://mcu-programming.blogspot.com/2006/09/lcd-interfacing.html

 

Welcome to EDABoard.com

Sponsor

Back
Top