Beruflich Dokumente
Kultur Dokumente
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2. ;
3. ; Comando de display LCD por medio de 4
bits a 20 MHz
4. ;
5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6.
7. LIST P=16F877A
8. INCLUDE <P16F877A.INC>
9. ERRORLEVEL -302
10.
11. __CONFIG
_CP_OFF&_DEBUG_OFF&_WRT_OFF&_CPD_OFF&_LVP_OFF&_BODEN_OF
F&_PWRTE_ON&_WDT_OFF&_HS_OSC
12.
13. ;....................................................
............................................
14.
15. #DEFINE LCD_RS PORTB,0
;Configuración de pines a usar con el LCD
16. #DEFINE LCD_E PORTB,1
17. #DEFINE LCD_D4 PORTB,2
18. #DEFINE LCD_D5 PORTB,3
19. #DEFINE LCD_D6 PORTB,4
20. #DEFINE LCD_D7 PORTB,5
21.
22. LCD_TEMP_1 EQU .32
23. LCD_CONTA_1 EQU .33
24. LCD_CONTA_2 EQU .34
25.
26. ;....................................................
............................................
27. org .0
28. bcf STATUS,RP0
29. bcf STATUS,RP1
30. goto INICIO
31.
32. org .4
33. bcf INTCON,GIE
34. retfie
35.
36. ;....................................................
............................................
37. RUTINA_15ms ;RUTINA DE DEMORA DE 15ms
38. movlw .75
39. movwf LCD_CONTA_2
40. goto QWE1
41. RUTINA_1ms ;RUTINA DE DEMORA DE 1ms
42. movlw .5
43. movwf LCD_CONTA_2
44. QWE1
45. movlw .249
46. movwf LCD_CONTA_1
47. QWE2
48. nop
49. decfsz LCD_CONTA_1,F
50. goto QWE2
51. decfsz LCD_CONTA_2,F
52. goto QWE1
53. return
54.
55. ;....................................................
............................................
56. LCD_INICIALIZAR
57. bcf LCD_E
58. bcf LCD_RS
59. call RUTINA_15ms ;demora para que el display
se resetee correctamente
60. movlw B'00110010' ;Setea 4 BITS
61. call LCD_IN
62. movlw B'00101000' ;Setea 2 lineas, matris de
5x7
63. call LCD_IN
64. movlw B'00000110' ;Activa el display,
desactiva el cursor y desactiva el destello del cursor
65. call LCD_INST
66. movlw B'00001100'
67. call LCD_INST
68. movlw B'00000001' ;BORRA DISPLAY
69. call LCD_INST
70. return
71.
72. ;.....................
73. LCD_IN
74. movwf LCD_TEMP_1
75. call SACAR
76. bsf LCD_E
77. call RUTINA_1ms
78. call RUTINA_1ms
79. call RUTINA_1ms
80. call RUTINA_1ms
81. bcf LCD_E
82. swapf LCD_TEMP_1,F
83. call SACAR
84. bsf LCD_E
85. call RUTINA_1ms
86. call RUTINA_1ms
87. call RUTINA_1ms
88. call RUTINA_1ms
89. bcf LCD_E
90. return
91.
92. ;.....................
93. LCD_INST
94. movwf LCD_TEMP_1
95. call SACAR
96. bsf LCD_E
97. call RUTINA_1ms
98. call RUTINA_1ms
99. bcf LCD_E
100. swapf LCD_TEMP_1,F
101. call SACAR
102. bsf LCD_E
103. call RUTINA_1ms
104. call RUTINA_1ms
105. bcf LCD_E
106. return
107.
108. ;.....................
109. LCD_DATO
110. movwf LCD_TEMP_1
111. call SACAR
112. bsf LCD_RS
113. bsf LCD_E
114. movlw .133
115. movwf LCD_CONTA_1
116. decfsz LCD_CONTA_1,F
117. goto $-1
118. bcf LCD_E
119. bcf LCD_RS
120. swapf LCD_TEMP_1,F
121. call SACAR
122. bsf LCD_RS
123. bsf LCD_E
124. movlw .133
125. movwf LCD_CONTA_1
126. decfsz LCD_CONTA_1,F
127. goto $-1
128. bcf LCD_E
129. bcf LCD_RS
130. return
131.
132. ;.....................
133. SACAR
134. bcf LCD_D4
135. btfsc LCD_TEMP_1,4
136. bsf LCD_D4
137. bcf LCD_D5
138. btfsc LCD_TEMP_1,5
139. bsf LCD_D5
140. bcf LCD_D6
141. btfsc LCD_TEMP_1,6
142. bsf LCD_D6
143. bcf LCD_D7
144. btfsc LCD_TEMP_1,7
145. bsf LCD_D7
146. return
147.
148. ;..............................................
..................................................
149.
150. INICIO
151. clrf PORTA
152. clrf PORTB
153. clrf PORTC
154. clrf PORTD
155. clrf PORTE
156.
157. bsf STATUS,RP0
158. movlw B'11111111' ;Configuro los
puertos
159. movwf TRISA
160. movlw B'11000000'
161. movwf TRISB
162. movlw B'11111111'
163. movwf TRISC
164. movlw B'11111111'
165. movwf TRISD
166. movlw B'11111111'
167. movwf TRISE
168. bcf STATUS,RP0
169.
170. call LCD_INICIALIZAR
171.
172. movlw H'80'
173. call LCD_INST
174. movlw A' '
175. call LCD_DATO
176. movlw A' '
177. call LCD_DATO
178. movlw A' '
179. call LCD_DATO
180. movlw A'H'
181. call LCD_DATO
182. movlw A'o'
183. call LCD_DATO
184. movlw A'l'
185. call LCD_DATO
186. movlw A'a'
187. call LCD_DATO
188. movlw A' '
189. call LCD_DATO
190. movlw A'M'
191. call LCD_DATO
192. movlw A'u'
193. call LCD_DATO
194. movlw A'n'
195. call LCD_DATO
196. movlw A'd'
197. call LCD_DATO
198. movlw A'o'
199. call LCD_DATO
200. movlw A' '
201. call LCD_DATO
202. movlw A' '
203. call LCD_DATO
204. movlw A' '
205. call LCD_DATO
206.
207. movlw H'C0'
208. call LCD_INST
209. movlw A' '
210. call LCD_DATO
211. movlw A' '
212. call LCD_DATO
213. movlw A' '
214. call LCD_DATO
215. movlw A' '
216. call LCD_DATO
217. movlw A'C'
218. call LCD_DATO
219. movlw A'h'
220. call LCD_DATO
221. movlw A'a'
222. call LCD_DATO
223. movlw A'l'
224. call LCD_DATO
225. movlw A'y'
226. call LCD_DATO
227. movlw A'2'
228. call LCD_DATO
229. movlw A'9'
230. call LCD_DATO
231. movlw A' '
232. call LCD_DATO
233. movlw A' '
234. call LCD_DATO
235. movlw A' '
236. call LCD_DATO
237. movlw A' '
238. call LCD_DATO
239. movlw A' '
240. call LCD_DATO
241. FGH
242. nop ; Una ves escrito en
la pantalla me quedo en este loop
243. goto FGH
244.
245. ;..............................................
..................................................
246.
247. END
Conversión a ASCII
Códigos ASCII:
Pantalla de código ASCII extendido en el PC IBM original:
Pantalla de código ASCII extendido en Windows
Los códigos ASCII menores de 32 (decimal, de 00h a 1Fh) son los llamados
carácteres de control. Se utilizan como comandos en los dispositivos serie y paralelo
(terminales, impresoras, etc) efectuando operaciones como: avance de papel,
retorno de carro, fin de transmisión, fin de archivo, etc. En condiciones normales, por
ejemplo en un editor de texto ASCII, son carácteres que no pueden representarse
gráficamente.
Gráá ficámente:
7 0 en hexadecimal (8 bits)
Lo transportamos a un programa: