You are on page 1of 13

; name: jp6284

; original name: mtrx628 oct 03, 2004


; jose pino
; special chars: 01 = 4 seconds pause / pausa
; 0a = End of message
; microcontroller pic 16f628 4 mhz
Disable comparators
; improved: oct 9, 2004
; initialize display memory / inicializa la memoria del display
; there variables are the ram memory For the display
variable type Byte c0 at 0x40 = 1111_1110
variable type Byte c1 at 0x41 = 1110_1001
variable type Byte c2 at 0x42 = 1111_1111
variable type Byte c3 at 0x43 = 1111_0000
variable type Byte c4 at 0x44 = 1111_0000
variable type Byte c5 at 0x45 = 1111_1111
variable type Byte c6 at 0x46 = 1111_1010
variable type Byte c7 at 0x47 = 1111_0101
variable type Byte c8 at 0x48 = 1111_1111
variable type Byte c9 at 0x49 = 1111_0001
variable type Byte c10 at 0x4a = 1111_0010
variable type Byte c11 at 0x4b = 1111_1111
variable type Byte c12 at 0x4c = 1111_1111
variable type Byte c13 at 0x4d = 1111_0000
variable type Byte c14 at 0x4e = 1111_0011
variable type Byte c15 at 0x4f = 1111_1111
variable type Byte c16 at 0x50 = 1111_0100
variable type Byte c17 at 0x51 = 1111_1111
variable type Byte c18 at 0x52 = 1111_0000
variable type Byte c19 at 0x53 = 1111_0111
variable type Byte c20 at 0x54 = 1111_1000
variable type Byte c21 at 0x55 = 1111_1111
variable type Byte c22 at 0x56 = 1111_0000
variable type Byte c23 at 0x57 = 1111_0000
variable type Byte c24 at 0x58 = 1111_1111
variable type Byte c25 at 0x59 = 1111_1111
variable type Byte c26 at 0x5a = 1111_1111
variable type Byte c27 at 0x5b = 1111_1111
variable type Byte c28 at 0x5c = 1111_1111
variable type Byte c29 at 0x5d = 1111_1111
variable type Byte c30 at 0x5e = 1111_1111

variable type Byte direccion = 0 ; Pointer(index) of message On EEPROM


variable type Byte caracter = 0 ; character
variable type Byte ancho = 0 ; how many bits wide is the character
variable type Byte indice = 0 ; data index
variable type Byte t_columnas = 31 ; controls how many columns On memory display
variable type Byte columna = 1
variable type Byte columnas = 24 ; controls how many columns On display
variable type Byte ultima_c = 0x40 + columnas
variable type Byte t_display = 0 ; controls speed of display
variable type Byte pausa = 0 ; controls pause
variable type Bit tdisp0 at t_display: 0
variable type Bit tdisp1 at t_display: 1
variable type Bit tdisp2 at t_display: 2
variable type Bit car0 at caracter: 0
variable type Bit car1 at caracter: 1
variable type Bit car2 at caracter: 2
variable type Bit car3 at caracter: 3
variable type Bit car4 at caracter: 4
variable type Bit car5 at caracter: 5
variable type Bit car6 at caracter: 6
variable type Bit car7 at caracter: 7
port b = all Output
port a = all Output
delay 1sec
; testing display code
pin a6 = On ; Enable data signal / activa el Bit de datos
For 25 loop ; turn off all leds
pin a7 = On ; send clock signal / envia un pulso al reloj shift register
delay 10msec
pin a7 = off
delay 10msec
End loop
pin a6 = On
For 3 loop
For 255 loop ; delay del scroll, >= lento
indice = 0x40 ; direccion donde comienza memoria display
pin a6 = On ; activa la columna a desplazar
; this code controls the display(scroll, columns, character display

While indice < ultima_c loop ; hace el barrido del display(cambiar al


FSR = indice ; ancho del display)
caracter = INDF ; FSR & INDF are microcontroller registers !
port b = all Input
pin a7 = off
pin a7 = On ; scroll display / desplaza la col.
pin a6 = off
port b = caracter ; display character row / despliega valor de la columna
port b = all Output
indice = indice + 1 ; Next column / siguiente columna
delay 500usecs
End loop
End loop ; End of the scroll / termina loop del scroll
End loop
; fin de test / End of test code
indice = 0x40 ; indicates the memory display address
; direccion de la memoria del display
For 26 loop ; limpia el display
FSR = indice ; clears display
INDF = 255
indice = indice + 1
End loop
; main loop here !
; programa principal aqui !

forever loop
If direccion = 128 Then ; se acabo el mensaje? despliega espacios
direccion = 0 ; pendiente a reiniciar desde el principio
End If ; no more data On EEPROM? start over
EEPROM get character from(direccion) ; lee dato / Read the character from the ee
pom
If caracter = 10 Then ; si caracter = 10, inicia de nuevo
caracter = " " ; If character = 10, start over
direccion = 255
End If
ancho = 4 ; Define el ancho de la letra si es diferente
; startdard character is 4 bits wide
If caracter = 1 Then ; si caracter = 1, una pausa de 4 secs
pausa = 50 ; If character = 1, pause the display

; this area is defined like "ROM", defines the characteres


; esta area del programa es como la memoria rom que contiene los caracteres

Else If caracter < 33 Then ; espacio / space


ancho = 3
Else If caracter < 64 Then
If caracter = "!" Then ; decodifica el caracter.
c24 = 1000_0010 ; decode characters from EEPROM
c25 = 1111_1111
ancho = 2 ; solo Define ancho si <> a 4
Else If caracter = 34 Then ; If wide Not defined, wide = 4 bits
c24 = 0100_0111
c25 = 0001_1111
c26 = 0100_0111
c27 = 1111_1111
Else If caracter = "#" Then
c24 = 0101_0101
c25 = 0000_0000
c26 = 0101_0101
c27 = 0000_0000
c28 = 0101_0101
c29 = 1111_1111
ancho = 6
Else If caracter = "$" Then
c24 = 0101_1010
c25 = 0000_0000
c26 = 0101_0101
c27 = 1111_1111
Else If caracter = "%" Then
c24 = 0100_1101
c25 = 0011_1011
c26 = 0101_0110
c27 = 1111_1111
Else If caracter = "&" Then
c24 = 0101_0101
c25 = 0110_1010
c26 = 0111_0100
c27 = 1111_1111
Else If caracter = "'" Then
c24 = 0100_0111
c25 = 1111_1111
ancho = 2
Else If caracter = "(" Then
c24 = 0111_0001
c25 = 0100_1110
c26 = 1111_1111
ancho = 3
Else If caracter = ")" Then
c24 = 0100_1110
c25 = 0111_0001
c26 = 1111_1111
ancho = 3
Else If caracter = "*" Then
c24 = 0101_0101
c25 = 0110_0011
c26 = 0101_0101
c27 = 1111_1111
Else If caracter = "+" Then
c24 = 0001_1011
c25 = 0001_0001
c26 = 0001_1011
c27 = 1111_1111
Else If caracter = "," Then
c24 = 0011_1110
c25 = 0011_1101
c26 = 1111_1111
ancho = 3
Else If caracter = "-" Then
c24 = 0001_1011
c25 = 0001_1011
c26 = 0001_1011
c27 = 1111_1111
Else If caracter = "." Then
c24 = 0001_1100
c25 = 1111_1111
ancho = 2
Else If caracter = "/" Then
c24 = 0011_1101
c25 = 0011_1011
c26 = 0011_0111
c27 = 1111_1111
Else If caracter = "0" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = "1" Then
c24 = 0000_0000
c25 = 1111_1111
ancho = 2
Else If caracter = "2" Then
c24 = 1110_1100
c25 = 1110_1010
c26 = 1111_0110
c27 = 1111_1111
Else If caracter = "3" Then
c24 = 0110_1010
c25 = 0110_1010
c26 = 1011_0101
c27 = 1111_1111
Else If caracter = "4" Then
c24 = 0110_0011
c25 = 0011_1011
c26 = 1011_0000
c27 = 1111_1111
Else If caracter = "5" Then
c24 = 1110_0010
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter = "6" Then
c24 = 1111_0001
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter = "7" Then
c24 = 0010_1100
c25 = 0010_1011
c26 = 1010_0111
c27 = 1111_1111
Else If caracter = "8" Then
c24 = 1111_0101
c25 = 1110_1010
c26 = 1111_0101
c27 = 1111_1111
Else If caracter = "9" Then
c24 = 1111_0110
c25 = 1110_1010
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = ":" Then
c24 = 0101_0101
c25 = 1111_1111
ancho = 2
Else If caracter = ";" Then
c24 = 0011_1110
c25 = 0101_0101
c26 = 1111_1111
ancho = 3
Else If caracter = "<" Then
c24 = 0101_1011
c25 = 0101_0101
c26 = 0010_1110
c27 = 1111_1111
Else If caracter = "=" Then
c24 = 0101_0101
c25 = 0101_0101
c26 = 0101_0101
c27 = 1111_1111
Else If caracter = ">" Then
c24 = 0010_1110
c25 = 0101_0101
c26 = 0101_1011
c27 = 1111_1111
Else If caracter = "?" Then
c24 = 0100_1111
c25 = 0110_1010
c26 = 0010_0111
c27 = 1111_1111
End If
Else If caracter < 96 Then
If caracter = "@" Then
c24 = 0111_0001
c25 = 0100_1110
c26 = 1000_0010
c27 = 0111_0010
c28 = 1111_1111
ancho = 5
Else If caracter = "A" Then
c24 = 1111_0000
c25 = 1110_1011
c26 = 1111_0000
c27 = 1111_1111
Else If caracter = "B" Then
c24 = 0000_0000
c25 = 1110_1010
c26 = 1111_0101
c27 = 1111_1111
Else If caracter = "C" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1110_1110
c27 = 1111_1111
Else If caracter = "D" Then
c24 = 0000_0000
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = "E" Then
c24 = 0000_0000
c25 = 1110_1010
c26 = 1110_1110
c27 = 1111_1111
Else If caracter = "F" Then
c24 = 0000_0000
c25 = 1110_1011
c26 = 1110_1011
c27 = 1111_1111
Else If caracter = "G" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1110_1000
c27 = 1111_1111
Else If caracter = "H" Then
c24 = 0000_0000
c25 = 1111_1011
c26 = 0000_0000
c27 = 1111_1111
Else If caracter = "I" Then
c24 = 0000_0000
c25 = 1111_1111
ancho = 2
Else If caracter = "J" Then
c24 = 1111_1110
c25 = 1111_1110
c26 = 1110_0001
c27 = 1111_1111
Else If caracter = "K" Then
c24 = 0000_0000
c25 = 1111_1011
c26 = 1110_0100
c27 = 1111_1111
Else If caracter = "L" Then
c24 = 0000_0000
c25 = 1111_1110
c26 = 1111_1110
c27 = 1111_1111
Else If caracter = "M" Then
c24 = 0000_0000
c25 = 1111_0111
c26 = 1111_1011
c27 = 1111_0111
c28 = 0000_0000
c29 = 1111_1111
ancho = 6
Else If caracter = "N" Then
c24 = 0000_0000
c25 = 1111_0111
c26 = 1111_1011
c27 = 0000_0000
c28 = 1111_1111
ancho = 5
Else If caracter = "O" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = "P" Then
c24 = 0000_0000
c25 = 1110_1011
c26 = 1111_0111
c27 = 1111_1111
Else If caracter = "Q" Then
c24 = 1111_0001
c25 = 1110_1100
c26 = 1111_0000
c27 = 1111_1111
Else If caracter = "R" Then
c24 = 0000_0000
c25 = 1110_1011
c26 = 1111_0100
c27 = 1111_1111
Else If caracter = "S" Then
c24 = 1111_0110
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter = "T" Then
c24 = 1110_1111
c25 = 0000_0000
c26 = 1110_1111
c27 = 1111_1111
Else If caracter = "U" Then
c24 = 1110_0001
c25 = 1111_1110
c26 = 1111_1110
c27 = 1110_0001
c28 = 1111_1111
ancho = 5
Else If caracter = "V" Then
c24 = 1110_0011
c25 = 1111_1101
c26 = 1111_1110
c27 = 1111_1101
c28 = 1110_0011
c29 = 1111_1111
ancho = 6
Else If caracter = "W" Then
c24 = 1110_0001
c25 = 1111_1110
c26 = 1111_1001
c27 = 1111_1110
c28 = 1110_0001
c29 = 1111_1111
ancho = 6
Else If caracter = "X" Then
c24 = 1110_0100
c25 = 1111_1011
c26 = 1110_0100
c27 = 1111_1111
Else If caracter = "Y" Then
c24 = 1110_0111
c25 = 1111_1000
c26 = 1110_0111
c27 = 1111_1111
Else If caracter = "Z" Then
c24 = 1110_1100
c25 = 1110_1010
c26 = 1110_0110
c27 = 1111_1111
Else If caracter = "[" Then
c25 = 1110_1110
c24 = 0000_0000
c26 = 1111_1111
ancho = 3
Else If caracter = "]" Then
c25 = 0000_0000
c24 = 1110_1110
c26 = 1111_1111
ancho = 3
Else If caracter = "\" Then
c26 = 1111_1101
c25 = 1111_1011
c24 = 1111_0111
c27 = 1111_1111
Else If caracter = "^" Then
c26 = 1111_0111
c25 = 1110_1111
c24 = 1111_0111
c27 = 1111_1111
Else If caracter = "_" Then
c24 = 1111_1110
c25 = 1111_1110
c26 = 1111_1110
ancho = 3
End If
Else If caracter < 128 Then
If caracter = "`" Then
c25 = 1111_0111
c24 = 1110_1111
c26 = 1111_1111
ancho = 3
Else If caracter = "a" Then
c26 = 1111_1000
c25 = 1111_0010
c24 = 1111_0101
c27 = 1111_1111
Else If caracter = "b" Then
c26 = 1111_1001
c25 = 1111_0110
c24 = 1110_0001
c27 = 1111_1111
Else If caracter = "c" Then
c26 = 1111_0110
c25 = 1111_0110
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "d" Then
c26 = 1110_0001
c25 = 1111_0110
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "e" Then
c26 = 1111_1010
c25 = 1111_0100
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "f" Then
c26 = 1110_1011
c25 = 1111_0000
c24 = 1111_1011
c27 = 1111_1111
Else If caracter = "g" Then
c26 = 1111_0001
c25 = 1111_0010
c24 = 1111_1010
c27 = 1111_1111
Else If caracter = "h" Then
c26 = 1111_1000
c25 = 1111_0111
c24 = 0000_0000
c27 = 1111_1111
Else If caracter = "i" Then
c24 = 1110_1000
c25 = 1111_1111
ancho = 2
Else If caracter = "j" Then
c26 = 1110_1001
c25 = 1111_1110
c24 = 1111_1101
c27 = 1111_1111
Else If caracter = "k" Then
c26 = 1111_0110
c25 = 1111_1001
c24 = 1111_0000
c27 = 1111_1111
Else If caracter = "l" Then
c26 = 1111_1110
c25 = 0000_0000
c24 = 1110_1110
c27 = 1111_1111
Else If caracter = "m" Then
c28 = 1111_1000
c25 = 1111_0111
c26 = 1111_1000
c27 = 1111_0111
c24 = 1111_1000
c29 = 1111_1111
ancho = 6
Else If caracter = "n" Then
c26 = 1111_1000
c25 = 1111_0111
c24 = 1111_1000
c27 = 1111_1111
Else If caracter = "o" Then
c24 = 1111_1001
c25 = 1111_0110
c26 = 1111_1001
c27 = 1111_1111
Else If caracter = "p" Then
c26 = 1111_1011
c25 = 1111_0101
c24 = 1111_1000
c27 = 1111_1111
Else If caracter = "q" Then
c26 = 1111_1000
c25 = 1111_0101
c24 = 1111_1011
c27 = 1111_1111
Else If caracter = "r" Then
c26 = 1111_0111
c25 = 1111_0111
c24 = 1111_1000
c27 = 1111_1111
Else If caracter = "s" Then
c26 = 1111_0101
c25 = 1111_0000
c24 = 1111_1010
c27 = 1111_1111
Else If caracter = "t" Then
c26 = 1111_0110
c25 = 1110_0001
c24 = 1111_0111
c27 = 1111_1111
Else If caracter = "u" Then
c26 = 1111_0001
c25 = 1111_1110
c24 = 1111_0001
c27 = 1111_1111
Else If caracter = "v" Then
c24 = 1111_0001
c25 = 1111_1100
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = "w" Then
c24 = 1111_0001
c25 = 1111_1110
c26 = 1111_0001
c27 = 1111_1110
c28 = 1111_0001
c29 = 1111_1111
ancho = 6
Else If caracter = "x" Then
c24 = 1111_0100
c25 = 1111_1011
c26 = 1111_0100
c27 = 1111_1111
Else If caracter = "y" Then
c26 = 1111_0001
c25 = 1111_1010
c24 = 1111_0110
c27 = 1111_1111
Else If caracter = "z" Then
c26 = 1111_0010
c25 = 1111_0000
c24 = 1111_0100
c27 = 1111_1111
Else If caracter = "{" Then
c26 = 1110_1110
c25 = 1110_0100
c24 = 1111_1011
c27 = 1111_1111
Else If caracter = "|" Then
c24 = 1110_0100
c25 = 1111_1111
ancho = 2
Else If caracter = "}" Then
c26 = 1111_1011
c25 = 1110_0100
c24 = 1110_1110
c27 = 1111_1111
Else If caracter = "~" Then
c26 = 1110_1111
c25 = 1110_0111
c24 = 1111_0111
c27 = 1111_1111
; Else If caracter = " " Then
; c24 = 1111_1111
; c25 = 1111_1111
; c26 = 1111_1111
; c27 = 1111_1111
End If
End If
While ancho > 0 loop ; cuando se despliegue el char, carga otro
; character done? take other character
; re - despliega las columnas que tienen todos los leds On
; display all columns with leds On
For 3 loop
indice = 0x40 ; direccion donde comienza memoria display
; address For ram memory used For the display
pin a6 = On ; activa la columna a desplazar
; activate column(data On shift register)
assembler nop ; really little delay / pequenia pausa
While indice < ultima_c loop ; hace el barrido del display(cambiar al
FSR = indice ; ancho del display)
caracter = INDF ; scroll display / INDF is a pic register
pin a7 = off ; send a clock signal To shift register
port b = all Input ; Disable port b - no display
; apaga los leds del puerto b
pin a7 = On ; desplaza la col./ scroy column
pin a6 = off ; clock signal To shift column
; senial de clock para pasar a la sig columna
If caracter = 0 Then
port b = 0000_0000
port b = all Output
delay 200usec ; activa el puerto b / activate port b & delay
End If
indice = indice + 1 ; siguiente columna / Next column On display
End loop
End loop
; fin del re - desplegado
; End of display procedure

; scroll procedure
; procedimiento del desplegado
For 9 loop ; scroll delay / desplegado >= lento
indice = 0x40 ; direccion donde comienza memoria display
; display memory address
pin a6 = On ; activa la columna a desplazar
; activate column To display
assembler nop ; little delay
While indice < ultima_c loop ; hace el barrido del display(cambiar al ancho del
display)
; loop While EEPROM have more chars
FSR = indice ; FSR & INDF are pic registers
caracter = INDF ; frs & INDF son registros del pic
pin a7 = off
port b = all Input ; turn off port b And scroll display
pin a7 = On ; desplaza la col.
port b = caracter ; despliega valor de la columna
port b = all Output ; turn On port b
pin a6 = off ; signal To clock On shift register
indice = indice + 1 ; siguiente columna / Next column
delay 200usec
End loop
End loop ; termina loop del scroll / End of scroll
; If no pause, scroll all display
; si no hay pausa, realiza es corrimiento del display
; scrolls the display memory
If pausa = 0 Then
c0 = c1
c1 = c2
c2 = c3
c3 = c4
c4 = c5
c5 = c6
c6 = c7
c7 = c8
c8 = c9
c9 = c10
c10 = c11
c11 = c12
c12 = c13
c13 = c14
c14 = c15
c15 = c16
c16 = c17
c17 = c18
c18 = c19
c19 = c20
c20 = c21
c21 = c22
c22 = c23
c23 = c24
c24 = c25
c25 = c26
c26 = c27
c27 = c28
c28 = c29
c29 = c30
ancho = ancho - 1 ; controla el momento de cargar otro caracter
Else ; controls when another character is needed
pausa = pausa - 1
End If
End loop ; si scroll = columnas, carga otro caracter
; If scroll = columns, load another character
direccion = direccion + 1
End loop

You might also like