Buenas, como ya mencioné en un post pasado, estoy realizando el control de 4 matrices de LED's 8x8, controlando las letras que se elijen mediante el celular, con un módulo Bluetooth, programando todo en assembler, con el PIC16F88.
Estoy tratando de ponerlas en cascada, y que las letras se vayan desplazando por las matrices. Logré ponerlos en cascada, y almenos en el simulador de proteus y MPLAB, el programa funciona bien, pero cuando lo conecto en la realidad, no funciona, todas las matrices aparecen con todos sus LED's encendidos, y no entiendo por qué, en el simulador funciona perfecto. Revisé varias veces el conexionado, todos los CLK y CS de las matrices están conectados entre ellos, y conecté el DIN al pic, y a los demás DIN les conecté el DOUT del otro. (Adjunto foto del circuito, el de verdad y el simulado en proteus).
El programa a continuación lo hice solo para probar las matrices en cascada, el que tiene configurada la transmisión bluetooth y funciona bien, es otro. Lo único que hace el siguiente programa es escribir mi nombre (Alan), constantemente.
LIST p=16F88
#INCLUDE <P16F88.INC>
ERRORLEVEL -302
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
CBLOCK 0x20
Timer
Register
Value
Register0
Value0
Register1
Value1
Register2
Value2
Register3
ENDC
CBLOCK 0x30
Value3
SendRegister
SendValue
Matrices
Matrices_temp
Temp
Contador
Letra
Temp1
ENDC
W_TEMP EQU 0x7D
STATUS_TEMP EQU 0x7E
PCLATH_TEMP EQU 0x7F
DATAEE ORG 0x2100
DE "MCHP"
RESET ORG 0x0000
PAGESEL START
GOTO START
ISR ORG 0x0004
MOVWF W_TEMP
MOVF STATUS,W
MOVWF STATUS_TEMP
MOVF PCLATH,W
MOVWF PCLATH_TEMP
MOVF PCLATH_TEMP,W
MOVWF PCLATH
MOVF STATUS_TEMP,W
MOVWF STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
RETFIE
START
movlw b'01100001'
BANKSEL OSCCON
movwf OSCCON
btfss OSCCON,IOFS
goto $-1
banksel PORTA
CLRF PORTA
banksel PORTB
CLRF PORTB
banksel ANSEL
clrf ANSEL
banksel TRISA
clrf TRISA
clrf TRISB
banksel OPTION_REG
movlw b'10000111'
movwf OPTION_REG
banksel INTCON
clrf INTCON
banksel PIR1
clrf PIR1
banksel PIE1
clrf PIE1
banksel PIR2
clrf PIR2
banksel PIE2
clrf PIE2
banksel PCON
clrf PCON
banksel ADCON0
clrf ADCON0
banksel ADCON1
movlw b'10000000'
movwf ADCON1
banksel PORTB
Setup
#define DIN PORTB,1
#define LOAD PORTB,2
#define CLK PORTB,3
movlw .4
movwf Matrices
clrw
call SetDecodeMode
movlw 0x0f
call SetIntensity
movlw 0x07
call SetScanLimit
call Display_ON
clrw
call SetDisplayTest
clrf Matrices
Main
call Cambiar_Matriz
movlw 'A'
call Bucle_letra
call Delay_1s
call Cambiar_Matriz
movlw 'L'
call Bucle_letra
call Delay_1s
call Cambiar_Matriz
movlw 'A'
call Bucle_letra
call Delay_1s
call Cambiar_Matriz
movlw 'N'
call Bucle_letra
call Delay_1s
call Clear_All
call Delay_1s
clrf Matrices
goto Main
Values
movlw .4
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Value, 0
movwf Value3
return
movlw .3
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Value,0
movwf Value2
return
movlw .2
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Value,0
movwf Value1
return
movf Value, 0
movwf Value0
return
Registers
movlw .4
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Register, 0
movwf Register3
return
movlw .3
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Register,0
movwf Register2
return
movlw .2
xorwf Matrices,0
btfss STATUS,Z
goto $+4
movf Register,0
movwf Register1
return
movf Register, 0
movwf Register0
return
Cambiar_Matriz
movlw .4
xorwf Matrices,0
btfsc STATUS,Z
goto Main
incf Matrices,1
return
;------------------------------------------------------------------------------------------------
; Retardos
;------------------------------------------------------------------------------------------------
Delay_1s
movlw .20
movwf Timer
call Delay_50ms
decfsz Timer,1
goto $-2
return
Delay_50ms
movlw .61
movwf TMR0
clrw
subwf TMR0,W
btfss STATUS,Z
goto $-3
return
;------------------------------------------------------------------------------------------------
; Enviar datos
;------------------------------------------------------------------------------------------------
Send
movf Matrices,0
movwf Matrices_temp
S1 call CS
movlw .16
bcf LOAD
Send_Loop
bcf DIN
btfsc SendRegister, 7
bsf DIN
rlf SendValue, 1
rlf SendRegister, 1
bsf CLK
nop
bcf CLK
addlw 0xff
btfss STATUS, Z
goto Send_Loop
decfsz Matrices_temp,1
goto S1
bsf LOAD
return
CS
movlw .4
xorwf Matrices_temp,0
btfss STATUS,Z
goto $+6
movf Register3, 0
movwf SendRegister
movf Value3,0
movwf SendValue
return
movlw .3
xorwf Matrices_temp,0
btfss STATUS,Z
goto $+6
movf Register2, 0
movwf SendRegister
movf Value2,0
movwf SendValue
return
movlw .2
xorwf Matrices_temp,0
btfss STATUS,Z
goto $+6
movf Register1, 0
movwf SendRegister
movf Value1,0
movwf SendValue
return
movf Register0, 0
movwf SendRegister
movf Value0, 0
movwf SendValue
return
;------------------------------------------------------------------------------------------------
; Configurar decode mode
;------------------------------------------------------------------------------------------------
SetDecodeMode
movwf Value0
movwf Value1
movwf Value2
movwf Value3
movlw 0x09
movwf Register0
movwf Register1
movwf Register2
movwf Register3
goto Send
;------------------------------------------------------------------------------------------------
; Configurar intensidad
;------------------------------------------------------------------------------------------------
SetIntensity
movwf Value0
movwf Value1
movwf Value2
movwf Value3
movlw 0x0a
movwf Register0
movwf Register1
movwf Register2
movwf Register3
goto Send
;------------------------------------------------------------------------------------------------
; Configurar columnas
;------------------------------------------------------------------------------------------------
SetScanLimit
movwf Value0
movwf Value1
movwf Value2
movwf Value3
movlw 0x0b
movwf Register0
movwf Register1
movwf Register2
movwf Register3
goto Send
;------------------------------------------------------------------------------------------------
; Configurar Shutdown
;------------------------------------------------------------------------------------------------
Display_ON
movlw 0x01
goto SetShutdown
Display_OFF
movlw 0x00
SetShutdown
movwf Value0
movwf Value1
movwf Value2
movwf Value3
movlw 0x0c
movwf Register0
movwf Register1
movwf Register2
movwf Register3
goto Send
;------------------------------------------------------------------------------------------------
; Configurar Test
;------------------------------------------------------------------------------------------------
SetDisplayTest
movwf Value0
movwf Value1
movwf Value2
movwf Value3
movlw 0x0f
movwf Register0
movwf Register1
movwf Register2
movwf Register3
goto Send
;------------------------------------------------------------------------------------------------
; Clarear
;------------------------------------------------------------------------------------------------
Clear_All
movlw .4
movwf Contador
movlw .1
movwf Matrices
r1 call Clear
decfsz Contador,1
goto $+2
return
incf Matrices,1
goto r1
Clear
movlw 0x00
movwf Temp
movlw 0x08
movwf Register
Bucle
call Registers
movf Temp, w
movwf Value
call Values
call Send
decfsz Register, 1
goto Bucle
return
;------------------------------------------------------------------------------------------------
; Letras
;------------------------------------------------------------------------------------------------
Bucle_letra
movwf Letra
movlw 0x01
movwf Register
r2 call Registers
call Elegir_letra
movwf Value
call Values
call Send
incf Contador,1
incf Register,1
movlw 0x09
xorwf Register,0
btfss STATUS,Z
goto r2
clrf Contador
return
Elegir_letra
movlw .4
movwf PCLATH
movlw 'A'
xorwf Letra,0
btfss STATUS,Z
goto $+3
call A_
return
movlw 'L'
xorwf Letra,0
btfss STATUS,Z
goto $+3
call L_
return
call N_
return
;------------------------------------------------------------------------------------------------
; Letras
;------------------------------------------------------------------------------------------------
ORG 0x400
A_
movf Contador,0
addwf PCL,f
retlw b'00000000'
retlw b'01111111'
retlw b'10001000'
retlw b'10001000'
retlw b'10001000'
retlw b'10001000'
retlw b'01111111'
retlw b'00000000'
L_
movf Contador,0
addwf PCL,f
retlw b'00000000'
retlw b'11111111'
retlw b'00000001'
retlw b'00000001'
retlw b'00000001'
retlw b'00000001'
retlw b'00000000'
retlw b'00000000'
N_
movf Contador,0
addwf PCL,f
retlw b'00000000'
retlw b'11111111'
retlw b'01110000'
retlw b'00111000'
retlw b'00011100'
retlw b'00001110'
retlw b'11111111'
retlw b'00000000'
ENDEn fin, si alguno tuvo un problema similar, o sabe la solución, por favor explíqueme que estoy haciendo mal.
Esto es lo que se ve al conectarlo...
PD: Les dejo adjunto el .hex y el .dsn de proteus por si quieren testearlo.