device 16f876
xtal 10
all_digital true
on_interrupt isr
hserial_baud = 9600
hserial_rcsta = %10010000
hserial_txsta = %00100100
hserial_clear = on
dim rtc as byte
dim cop as byte
dim tmp1 as byte
dim tmp2 as byte
dim tmp3 as byte
dim syc as byte
dim bir as byte 'bir
dim onn as byte 'on
dim yuz as byte 'yüz
dim ban as byte 'bin
dim bnm as byte 'on bin
dim r[5] as byte
dim i as byte
dim cnt as byte
dim val1 as byte
dim kval as byte
dim Col as byte
dim Row as byte
dim Key as byte
dim digval as byte
dim temp as byte
dim portval as byte
dim clkcount as byte
dim keyval as byte
dim timeshare as byte
dim wtmp as dword
dim keypad as bit
dim update as bit
symbol rst_17=PORTC.4
symbol clk_17=PORTC.5
symbol bl_51 =PORTA.5
symbol disp1 =PORTB.3'7
symbol disp2 =PORTB.4'6
symbol disp3 =PORTB.5'5
symbol disp4 =PORTB.6'4
symbol disp5 =PORTB.7'3
TRISA=0
TRISB=%00000111
TRISC=%10000000
'OPTION_REG=%11010100 'orjinal option reg
OPTION_REG=%11000100
INTCON=%00100000
cnt=0
syc=0
wtmp=0
clear
gosub rst_4017
gosub set_key
gosub xz
gosub move_dig
delayms 1000
TMR0=0
INTCON.2=0
INTCON.7=1
'keypad=0
goto main
isr: '10ms tick
if keypad=1 then isr01
portval = PORTB
portval=portval & 7
if clkcount > 10 then
gosub rst_4017
endif
if portval > 0 then
keypad=1
goto isr01
endif
keypad=0
gosub one_clk
clkcount = clkcount + 1
isr01:
'if update=0 then exit_isr
select case timeshare
case 0
disp5=0
PORTA=bir
disp1=1
case 1
disp1=0
PORTA=onn
disp2=1
case 2
disp2=0
PORTA=yuz
disp3=1
case 3
disp3=0
PORTA=ban
disp4=1
case 4
disp4=0
PORTA=bnm
disp5=1
end select
inc timeshare
if timeshare > 4 then timeshare=0
exit_isr:
inc rtc
INTCON.2=0
context restore
main:
if keypad=0 then main
get_val:
keyval = portval
'hserout [dec keyval,"----",dec clkcount,13,10]
'goto key_son
if keyval=1 then col1
if keyval=2 then col2
if keyval=4 then col4
goto key_son
'------------------------------------------------------------
col4:
select case clkcount
case 1':keyval=0
kval=0
gosub chk_cnt
break
case 2':keyval="A/P"
tmp1="A"
tmp2="T"
tmp3=14
goto send_232
case 3':keyval="KL"
tmp1="K"
tmp2="L"
tmp3=11
goto send_232
case 4':keyval="HDG"
tmp1="H"
tmp2="G"
tmp3=12
goto send_232
case 5':keyval="CRS"
tmp1="C"
tmp2="R"
tmp3=13
goto send_232
case 6':keyval="ALT"
tmp1="A"
tmp2="L"
tmp3=14
goto send_232
case 7':keyval="V/S"
tmp1="V"
tmp2="S"
tmp3=15
goto send_232
case 8':keyval="IAS"
tmp1="I"
tmp2="A"
tmp3=16
goto send_232
case 9':keyval="APR"
tmp1="A"
tmp2="T"
tmp3=17
goto send_232
case 10':keyval="CLR"
cnt=0
wtmp=0
gosub move_dig
break
end select
goto key_son
col2:
select case clkcount
case 1':keyval="000"
gosub mul_1000
gosub mul_1000
gosub mul_1000
break
case 2':keyval="QNH"
tmp1="M"
tmp2="H"
tmp3=18
goto send_232
case 3':keyval="Txp"
tmp1="X"
tmp2="P"
tmp3=19
goto send_232
case 4':keyval="ADF"
tmp1="A"
tmp2="1"
tmp3=20
goto send_232
case 5':keyval="nav2Stanby"
tmp1="N"
tmp2="2"
tmp3=21
goto send_232
case 6':keyval="nav1Aktif"
tmp1="N"
tmp2="1"
tmp3=22
goto send_232
case 7':keyval="com1Stanby"
tmp1="C"
tmp2="2"
tmp3=23
goto send_232
case 8':keyval="com1Aktif"
tmp1="C"
tmp2="1"
tmp3=24
goto send_232
case 9':keyval=3
kval=3
gosub chk_cnt
break
case 10':keyval=2
kval=2
gosub chk_cnt
break
end select
goto key_son
col1:
select case clkcount
case 1':keyval=1
kval=1
gosub chk_cnt
break
case 2':keyval=6
kval=6
gosub chk_cnt
break
case 3':keyval=5
kval=5
gosub chk_cnt
break
case 4':keyval=4
kval=4
gosub chk_cnt
break
case 5':keyval=9
kval=9
gosub chk_cnt
break
case 6':keyval=8
kval=8
gosub chk_cnt
break
case 7':keyval=7
kval=7
gosub chk_cnt
break
case 8':keyval=5
tmp1="A"
tmp2="0"
tmp3=10
goto send_232
case 9':keyval=7
tmp1="G"
tmp2="Z"
tmp3=26
goto send_232
case 10':keyval=9
tmp1="H"
tmp2="N"
tmp3=25
goto send_232
end select
goto key_son
mul_1000:
kval=0
chk_cnt:
inc cnt
if cnt > 5 then
cnt=0
gosub move_dig
return
endif
gosub move_dig
return
move_dig:
select case cnt
case 0
gosub temizle
break
case 1
r[0]=kval
break
case 2
r[1]=r[0]
r[0]=kval
break
case 3
r[2]=r[1]
r[1]=r[0]
r[0]=kval
break
case 4
r[3]=r[2]
r[2]=r[1]
r[1]=r[0]
r[0]=kval
break
case 5
r[4]=r[3]
r[3]=r[2]
r[2]=r[1]
r[1]=r[0]
r[0]=kval
break
else case
gosub temizle
goto xz
end select
wtmp=r[4] * 10000
wtmp=wtmp + (r[3] * 1000)
wtmp=wtmp + (r[2] * 100)
wtmp=wtmp + (r[1] * 10)
wtmp=wtmp + r[0]
xz:
if wtmp=0 then
bir=10 'blank
onn=10
yuz=10
ban=10
bnm=10
goto zx
endif
bir=dig wtmp,0
'onn=r[1]
'yuz=r[2]
'ban=r[3]
'bnm=r[4]
if wtmp < 10 then
onn=10
else
onn=dig wtmp,1
endif
if wtmp < 100 then
yuz=10
else
yuz=dig wtmp,2
endif
if wtmp < 1000 then
ban=10
else
ban=dig wtmp,3
endif
if wtmp < 10000 then
bnm=10
else
bnm=dig wtmp,4
endif
zx:
return
send_232:
if wtmp=0 then command
goto data_command
command:
select case tmp3
case 0
goto key_son
case 10
tmp1="A":tmp2="O":goto data_command
'case 11
' tmp1="N":tmp2="2":goto data_command
case 12
tmp1="A":tmp2="H":goto data_command
case 13
tmp1="A":tmp2="C":goto data_command
case 14
tmp1="A":tmp2="T":goto data_command
case 15
tmp1="A":tmp2="V":goto data_command
case 16
tmp1="A":tmp2="I":goto data_command
'case 17
' tmp1="N":tmp2="2":goto data_command
'case 18
' tmp1="N":tmp2="2":goto data_command
'case 19
' tmp1="N":tmp2="2":goto data_command
'case 20
' tmp1="N":tmp2="S":goto data_command
case 21
tmp1="N":tmp2="S":goto data_command
case 22
tmp1="N":tmp2="S":goto data_command
case 23
tmp1="C":tmp2="S":goto data_command
case 24
tmp1="C":tmp2="S":goto data_command
endselect
goto key_son
data_command:
'send_232:
tmp3=0
hserout ["@",tmp1,tmp2,dec5 wtmp,13,10]
gosub temizle
goto key_son
set_key:
clkcount=1
keyval=0
return
rst_4017:
rst_17=1
gosub wait100us
rst_17=0
clkcount = 1
return
one_clk:
clk_17=1
gosub wait100us
clk_17=0
return
wait100us:
delayus 100
return
temizle:
for i=0 to 4
r[i]=0
next
cnt=0
wtmp=0
bir=10 'blank
onn=10
yuz=10
ban=10
bnm=10
return
key_son:
cop=PORTB & 7
if cop > 0 then key_son
rtc=0
while rtc < 76
nop
wend
'wtmp=0
rtc=0
keypad=0
goto main
devrede ki kristal 10MHz olacak program Proton basic compailer ile yaz?lm??t?r.