Lcd 3 Pines

Páginas: 5 (1029 palabras) Publicado: 29 de octubre de 2012
Librería LCD con 3 pines para microcontroladores PIC
Publicado por Oscar Gonzalez en Electrónica el 01/12/2009 (10:30)
Etiquetas: librería, lcd, microcontrolador, pic, 16F84
. No hay comentarios

No todo va ser Arduino en ésta vida y Manuel desde MicroPic.es nos informa de una estupenda librería para manejo de pantallas LCD que utiliza tan sólo 3 pines para su control y un bus de datos de 4bits. La librería es muy sencilla y fué originalmente diseñada utilizando un microcontrolador PIC 16F84.
Código fuente y enlace a continuación...
Gracias Manuel!

Código fuente de la librería:
view plaincopy to clipboardprint?
1. // flex_lcd_3_pins.c
2.
3. //Modificación de Flex_lcd por Duende_Azul y Akenafab
4. //Trabaja con 3 pines y 74VHC164
5. //8-Bit Serial-In,Parallel-Out Shift Register
6.
7. //La LCD se usa en modo 4bits
8. //Revisar diagrama de conexion Adjunto
9. //Se ha utilizado a una velocidad de @40MHz sin ningun problema
10.
11. //No esta habilitada la lectura del LCD
12. //RW debe ir a gnd
13.
14. //Definir pines antes de llamar libreria//
15. //#define LCD_E PIN_A0
16. //#define LCD_CKPIN_A1
17. //#define LCD_DAT PIN_A2
18.
19. //========================================
20. int RS_bit;
21. #define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
22. #define lcd_line_two 0x40 // LCD RAM address for the 2nd line
23.
24.
25. int8 const LCD_INIT_STRING[4] =
26. {
27. 0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots28. 0xc, // Display on
29. 1, // Clear display
30. 6 // Increment cursor
31. };
32.
33.
34. //-------------------------------------
35. void lcd_send_nibble(int8 nibble, int rs_bit)
36. {
37.
38. int x;
39. if(RS_bit==1)
40. nibble=nibble|0x10;
41.
42. for(x=0;x<5;x++){
43.output_bit(LCD_DAT,shift_right(&nibble,1,0));
44. delay_cycles(1);
45. output_low(LCD_CK);
46. delay_us(1);
47. output_high(LCD_CK);}
48.
49. output_high(LCD_E);
50. delay_us(2);
51. output_low(LCD_E);
52. }
53.
54. //-----------------------------------
55. //----------------------------------------
56. // Send a byte to the LCD.
57. void lcd_send_byte(int8 address, int8n)
58. {
59. //output_low(LCD_RS);
60. RS_bit=0;
61. delay_us(100);
62.
63.
64. if(address)
65. //output_high(LCD_RS);
66. RS_bit=1;
67. else
68. //output_low(LCD_RS);
69. RS_bit=0;
70.
71. delay_cycles(1);
72.
73.
74. output_low(LCD_E);
75.
76. lcd_send_nibble(n >> 4,RS_bit);
77.lcd_send_nibble(n & 0xf,RS_bit);
78. }
79.
80. //----------------------------
81. void lcd_init(void)
82. {
83. int8 i;
84.
85. //output_low(LCD_RS);
86. RS_bit=0;
87.
88. output_low(LCD_E);
89.
90. delay_ms(20);
91.
92. for(i=0 ;i < 3; i++)
93. {
94. lcd_send_nibble(0x03,RS_bit);
95. delay_ms(5);
96. }97.
98. lcd_send_nibble(0x02,RS_bit);
99.
100. for(i=0; i < sizeof(LCD_INIT_STRING); i++)
101. {
102. lcd_send_byte(0, LCD_INIT_STRING[i]);
103.
104. delay_ms(5);
105.
106. }
107.
108. }
109.
110. //----------------------------
111.
112. void lcd_gotoxy(int8 x, int8 y)
113. {
114. int8 address;
115.116. if(y != 1)
117. address = lcd_line_two;
118. else
119. address=0;
120.
121. address += x-1;
122. lcd_send_byte(0, 0x80 | address);
123. }
124.
125. //-----------------------------
126. void lcd_putc(char c)
127. {
128. switch(c)
129. {
130. case 'f': //limpia pantalla
131. lcd_send_byte(0,1);
132. delay_ms(8);...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Definicionde Pines Lcd
  • La piña
  • Los pinos
  • piña
  • pino
  • LA PIÑA
  • LA piña
  • Pínidos

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS