Você está na página 1de 3

'----------------------------

'Programa de ejemplo display 7x32


'Texto fijo: POWER
'
'PIC: 16F628A - 4Mhz XTAL, SIN RESET
'
'----- CONFIGURO PUERTOS-----
PORTA = 0
CMCON = 7 'Configuro PORTA como Digital I/O
'
'Configuro el portA:
TRISA.0 = 0 'Salida CLOCK
TRISA.1 = 0 'Salida DATA
TRISA.2 = 1 'Entrada Dip 0
TRISA.3 = 1 'Entrada Dip 1
TRISA.4 = 1 'Entrada Dip 2
TRISA.5 = 1 'Entrada Dip 3
'
'Configuro el portB:
TRISB.0 = 0 'Salida (Fila 1)
TRISB.1 = 1 'Entrada RS-232
TRISB.2 = 0 'Salida (Fila 2)
TRISB.3 = 0 'Salida (Fila 3)
TRISB.4 = 0 'Salida (Fila 4)
TRISB.5 = 0 'Salida (Fila 5)
TRISB.6 = 0 'Salida (Fila 6)
TRISB.7 = 0 'Salida (Fila 7)
'
'Simbolos
Symbol clock = PORTA.0
Symbol data = PORTA.1
Symbol fila1 = PORTB.0
Symbol fila2 = PORTB.2
Symbol fila3 = PORTB.3
Symbol fila4 = PORTB.4
Symbol fila5 = PORTB.5
Symbol fila6 = PORTB.6
Symbol fila7 = PORTB.7
clock = 0
data = 0
'
'Declaracion de variables
Dim col As Byte
Dim aux As Word
'
PORTB = 255 'Apago todas las filas antes de comenzar
'
'---------BUCLE PRINCIPAL------------
Loop:
aux = %0001111011111010
Gosub escribo
aux = %0010011100011110
Gosub escribo
fila1 = 0
WaitMs 2
fila1 = 1
'
aux = %0010001000001010
Gosub escribo
aux = %0010100010100010
Gosub escribo
fila2 = 0
WaitMs 2
fila2 = 1
'
aux = %0010001000001010
Gosub escribo
aux = %0010100010100010
Gosub escribo
fila3 = 0
WaitMs 2
fila3 = 1
'
aux = %0001111000111010
Gosub escribo
aux = %0010100010011110
Gosub escribo
fila4 = 0
WaitMs 2
fila4 = 1
'
aux = %0000101000001010
Gosub escribo
aux = %1010100010000010
Gosub escribo
fila5 = 0
WaitMs 2
fila5 = 1
'
aux = %0001001000001001
Gosub escribo
aux = %1100100010000010
Gosub escribo
fila6 = 0
WaitMs 2
fila6 = 1
'
aux = %0010001011111001
Gosub escribo
aux = %0100011100000010
Gosub escribo
fila7 = 0
WaitMs 2
fila7 = 1
'
Goto loop
'
End
'
'Subrutina que llena el registro de dezplazamiento
escribo:
For col = 1 To 16
If aux.15 = 0 Then
data = 1
WaitUs 2
clock = 0
WaitUs 2
clock = 1
WaitUs 2
Else
data = 0
WaitUs 2
clock = 0
WaitUs 2
clock = 1
WaitUs 2
Endif
aux = ShiftLeft(aux, 1)
Next col
Return

Você também pode gostar