hola tengo un codigo que no engancha en basic donde puede estar el fallo parece que no me envia el word D
Device 16F628A
Xtal 4
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Declare LCD_Interface 4 ' imposta dati lcd a 4 fili
Declare LCD_Lines 2 ' imposta linee lcd
Declare LCD_DTPin PORTB.0 ' assegna porta C4 alla DT lcd
Declare LCD_ENPin PORTA.3 ' assegna porta B6 alla EN lcd
Declare LCD_RSPin PORTA.2 ' assegna porta B5 alla RS lcd
All_Digital true
Dim mem2 As Byte
Dim mem1 As Byte
Dim frequenza As Word
Dim ultimafreq As Word
Dim frequenzaR As Word
Symbol Up = PORTA.0
Symbol Down = PORTA.1
Symbol lock = PORTA.4
Symbol clb = PORTB.4
Symbol dlen = PORTB.5
Symbol dataa = PORTB.6
''''''''''''''''''''''''''''''''''''''''''''''''''''
TRISA.0 = 1
TRISA.1 = 1
TRISA.4 = 1
TRISB.4 = 0
TRISB.5 = 0
TRISB.6 = 0
clb = 0
dlen = 0
dataa = 0
DelayMS 200
' WordB 01110110010101
'0101 'Controllo del pin 18
'0000=1; 0001= contatore prg; 0100=Frec. Ref.; 0101=Lock/Unlock
'1 BRM controllo del bus 1 = sw automatico; 0 = sempre in ON
'00 PDM Detector di fase digital 0X = on/off automatico; 10 = on; 11 = off
'1 SLA Modo Latch A 1 = síncrono; 0 = asíncrono
'1 SB2 on/off ultimi 8 bits della wordB 1 = on; 0 = off.
'(da SLA a T0) 0, gli ultimi 8 bit sono collocati in 00000000
'1110 Guadagno di corrente per la tensione di errore 0000=0.023; 0001=0.07; 0010=0.23; 0110=0.7; 1110=2,3
'0 Freq.rifermento 0 = 1Khz; 1 = 1.25Khz
'1 modo FM/AM; 1 = FM; 0 = AM
EWrite 0,[232,3,0] ' EEPROM 3,232 = 1000 = 100.0 Mhz
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
mem1 = ERead 0
mem2 = ERead 1
frequenza = mem2 * 256 +mem1
ultimafreq = frequenza
Low dlen
DelayMS 100
Print At 1,1,"TEST PLL 1 "
DelayMS 1000 'wait
Cls
'''''''Write WordB SAA1057
dlen = 1
SHOut dataa, clb, 1, [01110110010101]
dlen = 0
dataa = 0
DelayUS 5
clb = 1
DelayUS 1
clb = 0
DelayMS 100
GoSub wiritefreq ' write @saa1057
GoSub writelcd 'write @ LCD
Cls
DelayMS 100
'*******************START********************
loopstart:
GoSub writelcd
If Up=1 Then
DelayMS 200
frequenza = frequenza + 1
If frequenza < 1081 Then
Else
frequenza = 1080
EndIf
EndIf
If Down = 1 Then
DelayMS 200
frequenza = frequenza-1
If frequenza > 874 Then
Else
frequenza = 875
EndIf
EndIf
DelayMS 1
'''''''''''''''''''''''''''''''
If lock = 0 Then
Print At 1,1, "Unlock"
lock = 0
Else
Print At 1,1, "Lock "
lock = 1
EndIf
DelayMS 1
GoTo loopstart
'''''''''''''''''''''''''''''''''''write @saa1057
wiritefreq:
frequenzaR = frequenza * 10
dlen = 1
SHOut dataa, clb, 1, [frequenzaR\16]
dlen = 0
dataa = 0
DelayUS 5
clb = 1
DelayUS 1
clb = 0
DelayMS 1
Return
'***************************************************
writelcd:
mem1 = frequenza
mem2 = (frequenza-mem1)/256
If ultimafreq <> frequenza Then
EWrite 0, [mem1]
EWrite 1, [mem2]
EndIf
GoSub wiritefreq
If frequenza < 1000 Then
Print At 1,9, Dec (frequenza/10), ".", Dec1 frequenza, "Mhz"
Print At 2,1,@frequenzaR
Else
Print At 1,9, Dec (frequenza/10), ".", Dec1 frequenza, "Mhz"
Print At 2,1,@frequenzaR
EndIf
Return
End
Device 16F628A
Xtal 4
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Declare LCD_Interface 4 ' imposta dati lcd a 4 fili
Declare LCD_Lines 2 ' imposta linee lcd
Declare LCD_DTPin PORTB.0 ' assegna porta C4 alla DT lcd
Declare LCD_ENPin PORTA.3 ' assegna porta B6 alla EN lcd
Declare LCD_RSPin PORTA.2 ' assegna porta B5 alla RS lcd
All_Digital true
Dim mem2 As Byte
Dim mem1 As Byte
Dim frequenza As Word
Dim ultimafreq As Word
Dim frequenzaR As Word
Symbol Up = PORTA.0
Symbol Down = PORTA.1
Symbol lock = PORTA.4
Symbol clb = PORTB.4
Symbol dlen = PORTB.5
Symbol dataa = PORTB.6
''''''''''''''''''''''''''''''''''''''''''''''''''''
TRISA.0 = 1
TRISA.1 = 1
TRISA.4 = 1
TRISB.4 = 0
TRISB.5 = 0
TRISB.6 = 0
clb = 0
dlen = 0
dataa = 0
DelayMS 200
' WordB 01110110010101
'0101 'Controllo del pin 18
'0000=1; 0001= contatore prg; 0100=Frec. Ref.; 0101=Lock/Unlock
'1 BRM controllo del bus 1 = sw automatico; 0 = sempre in ON
'00 PDM Detector di fase digital 0X = on/off automatico; 10 = on; 11 = off
'1 SLA Modo Latch A 1 = síncrono; 0 = asíncrono
'1 SB2 on/off ultimi 8 bits della wordB 1 = on; 0 = off.
'(da SLA a T0) 0, gli ultimi 8 bit sono collocati in 00000000
'1110 Guadagno di corrente per la tensione di errore 0000=0.023; 0001=0.07; 0010=0.23; 0110=0.7; 1110=2,3
'0 Freq.rifermento 0 = 1Khz; 1 = 1.25Khz
'1 modo FM/AM; 1 = FM; 0 = AM
EWrite 0,[232,3,0] ' EEPROM 3,232 = 1000 = 100.0 Mhz
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
mem1 = ERead 0
mem2 = ERead 1
frequenza = mem2 * 256 +mem1
ultimafreq = frequenza
Low dlen
DelayMS 100
Print At 1,1,"TEST PLL 1 "
DelayMS 1000 'wait
Cls
'''''''Write WordB SAA1057
dlen = 1
SHOut dataa, clb, 1, [01110110010101]
dlen = 0
dataa = 0
DelayUS 5
clb = 1
DelayUS 1
clb = 0
DelayMS 100
GoSub wiritefreq ' write @saa1057
GoSub writelcd 'write @ LCD
Cls
DelayMS 100
'*******************START********************
loopstart:
GoSub writelcd
If Up=1 Then
DelayMS 200
frequenza = frequenza + 1
If frequenza < 1081 Then
Else
frequenza = 1080
EndIf
EndIf
If Down = 1 Then
DelayMS 200
frequenza = frequenza-1
If frequenza > 874 Then
Else
frequenza = 875
EndIf
EndIf
DelayMS 1
'''''''''''''''''''''''''''''''
If lock = 0 Then
Print At 1,1, "Unlock"
lock = 0
Else
Print At 1,1, "Lock "
lock = 1
EndIf
DelayMS 1
GoTo loopstart
'''''''''''''''''''''''''''''''''''write @saa1057
wiritefreq:
frequenzaR = frequenza * 10
dlen = 1
SHOut dataa, clb, 1, [frequenzaR\16]
dlen = 0
dataa = 0
DelayUS 5
clb = 1
DelayUS 1
clb = 0
DelayMS 1
Return
'***************************************************
writelcd:
mem1 = frequenza
mem2 = (frequenza-mem1)/256
If ultimafreq <> frequenza Then
EWrite 0, [mem1]
EWrite 1, [mem2]
EndIf
GoSub wiritefreq
If frequenza < 1000 Then
Print At 1,9, Dec (frequenza/10), ".", Dec1 frequenza, "Mhz"
Print At 2,1,@frequenzaR
Else
Print At 1,9, Dec (frequenza/10), ".", Dec1 frequenza, "Mhz"
Print At 2,1,@frequenzaR
EndIf
Return
End