Haberler:

Forum kuralları güncellendi LÜTFEN  okuyunuz:  https://bit.ly/2IjR3ME

Ana Menü

90 Ledli Kum Saati problemim

Başlatan bederik, 01 Mayıs 2015, 10:18:45

bederik



Sn. Arkadaşalar 90 ledli kum saati projesi verildi. devrenin taramasınında 4017, sütun bilgileri için 74595, işlemci olarak 16F628A kullandım. Benim düşünceme göre çalışması gerekiyor fakat ikinci taramanın 3ncü ile 6ncı sırasında isis kilitleniyor. işin kötüsü pic'e yüklediğimde pic te kilitleniyor. Sorunu çözmemde yardımcı olabilirmisiniz.
CMCON=7
TRISA=%00000000
TRISB=%11000000
PORTB=0
DEFINE OSC 4
X VAR BYTE
SUT1 VAR BYTE  [18]40
SUT2 VAR BYTE  [18]58
SUT3 VAR BYTE  [18]76
TEMP VAR BYTE

O VAR BYTE
P VAR BYTE
R VAR BYTE
A var byte
SAYI VAR BYTE
YERI VAR BYTE
VERI VAR BYTE
SYMBOL CLK=PORTA.0
SYMBOL DTA=PORTA.1
SYMBOL STL=PORTA.2
SYMBOL CL1=PORTB.0
SYMBOL RES1=PORTB.1
SYMBOL CL2=PORTB.2
SYMBOL RES2=PORTB.3
I VAR BYTE       
K VAR WORD       
M VAR BYTE       
L vAR BYTE       
L=0
M=0
K=0
BASLA:
IF M=0 THEN GOSUB SAYDIR
IF M>0 THEN             'EGER M 0-DAN BÜYÜKSE
K=K+1                   'K-YA 1 EKLE
IF K=30000 THEN           'EGER K 10000 OLDUYSA
M=M+1                   'M-YE 1 EKLE
IF M>46 THEN            'EGER M 46-DAN BUYUKSE
M=46                    'M 46
ENDIF
K=0                     'K=0
ENDIF
GOSUB ARA
GOSUB TE
GOSUB GOSTER
ENDIF
GOTO BASLA

SAYDIR:
IF PORTB.6=1 aND PORTB.7=0 THEN       '1.BÖLÜM 1 İSE
HIGH PORTB.4            '1. BÖLÜMÜ PASİF ET
LOW PORTB.5             '2.BÖLÜMÜ AKTİF ET
endIF
IF PORTB.7=1 AND PORTB.6=0 THEN
HIGH PORTB.5
LOW PORTB.4
ENDIF
IF PORTB.6=0 AND PORTB.7=0 THEN '1. VE 2.BÖLÜM O İSE YANİ İLK AÇILIŞ
HIGH CL1                '1.BÖLÜME CLOCK VER
ELSE
HIGH CL1
HIGH CL2
ENDIF
IF L=0 THEN
IF PORTB.7=1 AND PORTB.6=1 THEN       '2.BÖLÜM 1 OLDUYSA 
L=1                     'L DEĞİŞKENİ 1.SATIRDA
M=1                     'M DEGİŞKENİNİ 1 YAP
HIGH PORTB.5            '2. BÖLÜMÜ PASİF ET
LOW PORTB.4             '1.BÖLÜMÜ AKTİF ET
HIGH CL1                '1. BÖLÜME CLOCK VER
ELSE
IF PORTB.7=1 AND PORTB.6=1 THEN
HIGH PORTB.5
LOW PORTB.4
HIGH CL1
ENDIF
ENDIF
ENDIF
PAUSEUS 5000
LOW CL1                 '1. BÖLÜMÜN CLOCKUNU KES
LOW CL2                 '2.BÖLÜMÜN  CLOKUNU KES
RETURN

TE:
    TEMP=O
    FOR I=0 to 17
    YERI=TEMP+I
    IF M<30 THEN
    GOSUB DATAAL1
    ELSE
    GOSUB DATAAL3
    ENDIF
    SUT1[I]=VERI
    NEXT 

    TEMP=P
    FOR I=0 to 17
    YERI=TEMP+I
    IF M<16 THEN
    GOSUB DATAAL1
    ENDIF
    IF M>15 AND M<29 THEN
    GOSUB DATAAL2
    ENDIF
    IF M>28 AND M<44 THEN
    GOSUB DATAAL3
    ENDIF
    IF M>43 THEN
    GOSUB DATAAL4
    ENDIF
    SUT2[I]=VERI
    NEXT 

    TEMP=R
    FOR I=0 to 17
    YERI=TEMP+I
    IF M<15 THEN
    GOSUB DATAAL1
    ENDIF
    IF M>14 AND M<31 THEN
    GOSUB DATAAL2
    ENDIF
    IF M>30 AND M<43 THEN
    GOSUB DATAAL3
    ENDIF
    IF M>42 THEN
    GOSUB DATAAL4
    ENDIF
    SUT3[I]=VERI
    NEXT 
RETURN

ARA:
SELECT CASE M
case 1:O=0:P=0:R=0:return
CASE 2:O=0:P=18:R=0:RETURN
case 3:O=0:P=36:R=0:return
case 4:O=0:P=36:R=54:return
case 5:O=0:P=72:R=54:return
case 6:O=0:P=72:R=90:return
case 7:O=0:P=108:R=90:return
case 8:O=0:P=126:R=90:return
case 9:O=0:P=126:R=144:return
case 10:O=0:P=162:R=144:return
case 11:O=0:P=162:R=180:return
case 12:O=0:P=198:R=180:return
case 13:O=0:P=198:R=216:return
case 14:O=0:P=234:R=216:return
case 15:O=0:P=234:R=0:return
CASE 16:O=0:P=18:R=0:RETURN
case 17:O=0:P=36:R=0:return
case 18:O=0:P=36:R=54:return
case 19:O=0:P=72:R=54:return
case 20:O=0:P=72:R=90:return
case 21:O=0:P=108:R=90:return
case 22:O=0:P=108:R=126:return
case 23:O=0:P=144:R=126:return
case 24:O=0:P=144:R=162:return
case 25:O=0:P=180:R=162:return
case 26:O=0:P=180:R=198:return
case 27:O=0:P=216:R=198:return
case 28:O=0:P=216:R=234:return
case 29:O=0:P=0:R=234:return
CASE 30:O=18:P=0:R=234:RETURN
case 31:O=18:P=0:R=36:return
case 32:O=18:P=54:R=36:return
case 33:O=18:P=54:R=72:return
case 34:O=18:P=90:R=72:return
case 35:O=18:P=90:R=108:return
case 36:O=18:P=126:R=108:return
case 37:O=18:P=126:R=144:return
case 38:O=18:P=162:R=144:return
case 39:O=18:P=162:R=180:return
case 40:O=18:P=198:R=180:return
case 41:O=18:P=198:R=216:return
case 42:O=18:P=234:R=216:return
case 43:O=18:P=234:R=0:return
CASE 44:O=18:P=18:R=0:RETURN
case 45:O=18:P=18:R=36:return
case 46:O=18:P=54:R=36:return
END SELECT
return

GOSTER:

'FOR X= 1 TO SON
FOR I=0 to 17
SAYI=SUT3[I]
GOSUB AKTAR

SAYI=SUT2[I]
GOSUB AKTAR

SAYI=SUT1[I]
GOSUB AKTAR 

STL=1:PAUSEus 10 :STL=0
GOSUB SAYDIR
NEXT
RETURN

AKTAR:
SHIFTOUT DTA,CLK,1,[SAYI]
RETURN

DATAAL1:
lookup YERI,[$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00_      '0  
            ,$FE,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$01_      '1  18
            ,$FA,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$05_      '2  36
            ,$1F,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$40_      '3  54
            ,$FA,$F8,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$02,$05_      '4  72
            ,$1F,$2F,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$80,$40_      '5  90
            ,$FA,$F8,$F4,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$01,$02,$05_      '6  108
            ,$40,$F8,$F4,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$01,$02,$15_      '7  126
            ,$0F,$2F,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$80,$50_      '8  144
            ,$40,$F0,$F4,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$01,$0A,$15_      '9  162
            ,$0F,$0F,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$A0,$50_      '10 180
            ,$40,$F0,$F0,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$05,$0A,$15_      '11 198
            ,$0F,$0F,$1F,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$40,$A0,$50_      '12 216
            ,$40,$F0,$F0,$F8,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$02,$05,$0A,$15],VERI '13 234 
return                          

DATAAL2:
LOOKUP YERI,[$0F,$0F,$1F,$2F,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$80,$40,$A0,$50_      '14    0
            ,$40,$F0,$F0,$F8,$F4,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$01,$02,$05,$0A,$15_      '15    18
            ,$00,$F0,$F0,$F8,$F4,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$01,$02,$05,$0A,$55_      '16    36
            ,$01,$0F,$1F,$2F,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$80,$40,$A0,$54_      '17    54
            ,$00,$80,$F0,$F8,$F4,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$01,$02,$05,$2A,$55_      '18    72
            ,$01,$02,$1F,$2F,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$80,$40,$A8,$54_      '19    90
            ,$00,$80,$40,$F8,$F4,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$01,$02,$15,$2A,$55_      '20    108
            ,$01,$02,$0F,$2F,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$80,$50,$A8,$54_      '21    126
            ,$00,$80,$40,$F0,$F4,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$01,$0A,$15,$2A,$55_      '22    144
            ,$01,$02,$0F,$0F,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$A0,$50,$A8,$54_      '23    162
            ,$00,$80,$40,$F0,$F0,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$05,$0A,$15,$2A,$55_      '24    180
            ,$01,$02,$0F,$0F,$1F,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$40,$A0,$50,$A8,$54_      '25    198
            ,$00,$80,$40,$F0,$F0,$F8,$F4,$FF,$FF,$00,$00,$00,$02,$05,$0A,$15,$2A,$55_      '26    216
            ,$01,$02,$0F,$0F,$1F,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$40,$A0,$50,$A8,$54],VERI '27    234
return                          

DATAAL3:
LOOKUP YERI,[$00,$80,$40,$F0,$F0,$F8,$F4,$F2,$FF,$00,$00,$01,$02,$05,$0A,$15,$2A,$55_       '28   0
            ,$00,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$FF_       '29   18
            ,$00,$02,$0F,$0F,$1F,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$40,$A0,$50,$A8,$55_       '30   36
            ,$00,$00,$40,$F0,$F0,$F8,$F4,$F2,$FF,$00,$00,$01,$02,$05,$0A,$15,$AA,$55_       '31   54
            ,$00,$00,$0F,$0F,$1F,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$40,$A0,$50,$AA,$55_       '32   72
            ,$00,$00,$00,$F0,$F0,$F8,$F4,$F2,$FF,$00,$00,$01,$02,$05,$0A,$55,$AA,$55_       '33   90
            ,$00,$00,$00,$0F,$1F,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$40,$A0,$54,$AA,$55_       '34   108
            ,$00,$00,$00,$00,$F0,$F8,$F4,$F2,$FF,$00,$00,$01,$02,$05,$2A,$55,$AA,$55_       '35   126
            ,$00,$00,$00,$00,$1F,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$40,$A8,$54,$AA,$55_       '36   144
            ,$00,$00,$00,$00,$00,$F8,$F4,$F2,$FF,$00,$00,$01,$02,$15,$2A,$55,$AA,$55_       '37   162
            ,$00,$00,$00,$00,$00,$2F,$FF,$FF,$FF,$00,$00,$00,$80,$50,$A8,$54,$AA,$55_       '38   180
            ,$00,$00,$00,$00,$00,$00,$F4,$F2,$FF,$00,$00,$01,$0A,$15,$2A,$55,$AA,$55_       '39   198
            ,$00,$00,$00,$00,$00,$00,$FF,$FF,$FF,$00,$00,$00,$A0,$50,$A8,$54,$AA,$55_       '40   216
            ,$00,$00,$00,$00,$00,$00,$00,$F2,$FF,$00,$00,$05,$0A,$15,$2A,$55,$AA,$55],VERI  '41   234
return                          

DATAAL4:
LOOKUP YERI,[$00,$00,$00,$00,$00,$00,$00,$FF,$FF,$00,$00,$40,$A0,$50,$A8,$54,$AA,$55_        '42     0
            ,$00,$00,$00,$00,$00,$00,$00,$00,$FF,$00,$02,$05,$0A,$15,$2A,$55,$AA,$55_        '43     18
            ,$00,$00,$00,$00,$00,$00,$00,$00,$FF,$00,$80,$40,$A0,$50,$A8,$54,$AA,$55_        '44     36
            ,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$02,$05,$0A,$15,$2A,$55,$AA,$55],VERI   '45     54
return