when simulating in proteus, errors occur:Code:'=============================================================================== @ device INTRC_OSC_NOCLKOUT @ device wdt_off @ device pwrt_on @ device protect_off include "Tanimlar.inc" '=============================================================================== Ana: gosub Chk_KEYPAD if say = 3 then gosub kilit endif pause 1 goto Ana '=============================================================================== Chk_KEYPAD: for row = 0 to 3 PORTB = (dcd row) ^ $f pause 1 col = PORTB >> 4 if (col <> $f) then 'tuşa basıldı key = (row * 3) + (ncd (col ^ $f)) low buz pause 70 high buz while (PORTB >> 4) <> $f pause 1 wend if key = 11 then key = 0 TusBuff[tussay] = key if psw.0 = 0 then gosub Chk_tussay else gosub chk_tussay2 endif key = 255 endif next return '=============================================================================== Beep: high ld1 low buz pause 70 high buz pause 70 low buz pause 70 low ld1 high buz return '=============================================================================== Chk_SfrOK: psw.1 = 0 psw.2 = 0 psw.3 = 0 psw.4 = 0 psw.5 = 0 psw.6 = 0 if (TusBuff[0] = SfrBuff[0]) and (TusBuff[1] = SfrBuff[1]) and (TusBuff[2] = SfrBuff[2]) and (TusBuff[3] = SfrBuff[3]) then psw.1 = 1 if (TusBuff[0] = SfrBuff[4]) and (TusBuff[1] = SfrBuff[5]) and (TusBuff[2] = SfrBuff[6]) and (TusBuff[3] = SfrBuff[7]) then psw.2 = 1 if (TusBuff[0] = SfrBuff[8]) and (TusBuff[1] = SfrBuff[9]) and (TusBuff[2] = SfrBuff[10]) and (TusBuff[3] = SfrBuff[11]) then psw.3 = 1 if (TusBuff[0] = SfrBuff[12]) and (TusBuff[1] = SfrBuff[13]) and (TusBuff[2] = SfrBuff[14]) and (TusBuff[3] = SfrBuff[15]) then psw.4 = 1 if (TusBuff[0] = SfrBuff[16]) and (TusBuff[1] = SfrBuff[17]) and (TusBuff[2] = SfrBuff[18]) and (TusBuff[3] = SfrBuff[19]) then psw.5 = 1 if (TusBuff[0] = MKSfrBuff[0]) and (TusBuff[1] = MKSfrBuff[1]) and (TusBuff[2] = MKSfrBuff[2]) and (TusBuff[3] = MKSfrBuff[3]) then psw.6 = 1 if psw.1 = 0 and psw.2 = 0 and psw.3 = 0 and psw.4 = 0 and psw.5 = 0 and psw.6 = 0 then if TusBuff[tussay] = 12 or TusBuff[tussay] = 10 then if psw.6 = 0 then gosub Hata endif endif endif return '=============================================================================== Chk_NewSfrOK: psw.1 = 0 psw.2 = 0 psw.3 = 0 psw.4 = 0 psw.5 = 0 psw.6 = 0 if (TusBuff[5] = TusBuff[10]) and (TusBuff[6] = TusBuff[11]) and (TusBuff[7] = TusBuff[12]) and (TusBuff[8] = TusBuff[13]) then psw.1 = 1 psw.6 = 1 endif return '=============================================================================== Sifre_Degis: if psw.1 then SfrBuff[0] = TusBuff[5] SfrBuff[1] = TusBuff[6] SfrBuff[2] = TusBuff[7] SfrBuff[3] = TusBuff[8] endif if psw.2 then SfrBuff[4] = TusBuff[5] SfrBuff[5] = TusBuff[6] SfrBuff[6] = TusBuff[7] SfrBuff[7] = TusBuff[8] endif if psw.3 then SfrBuff[8] = TusBuff[5] SfrBuff[9] = TusBuff[6] SfrBuff[10] = TusBuff[7] SfrBuff[11] = TusBuff[8] endif if psw.4 then SfrBuff[12] = TusBuff[5] SfrBuff[13] = TusBuff[6] SfrBuff[14] = TusBuff[7] SfrBuff[15] = TusBuff[8] endif if psw.5 then SfrBuff[16] = TusBuff[5] SfrBuff[17] = TusBuff[6] SfrBuff[18] = TusBuff[7] SfrBuff[19] = TusBuff[8] endif Write 0, SfrBuff[0] 'Yeni şifre EEprom'un 0..3 adreslerine kaydedildi Write 1, SfrBuff[1] Write 2, SfrBuff[2] Write 3, SfrBuff[3] Write 4, SfrBuff[4] 'Yeni şifre EEprom'un 0..3 adreslerine kaydedildi Write 5, SfrBuff[5] Write 6, SfrBuff[6] Write 7, SfrBuff[7] Write 8, SfrBuff[8] 'Yeni şifre EEprom'un 0..3 adreslerine kaydedildi Write 9, SfrBuff[9] Write 10, SfrBuff[10] Write 11, SfrBuff[11] Write 12, SfrBuff[12] 'Yeni şifre EEprom'un 0..3 adreslerine kaydedildi Write 13, SfrBuff[13] Write 14, SfrBuff[14] Write 15, SfrBuff[15] Write 16, SfrBuff[16] 'Yeni şifre EEprom'un 0..3 adreslerine kaydedildi Write 17, SfrBuff[17] Write 18, SfrBuff[18] Write 19, SfrBuff[19] return '=============================================================================== Chk_tussay: select case tussay case 4 gosub Chk_SfrOK if psw.1 or psw.2 or psw.3 or psw.4 or psw.5 or psw.6 then if TusBuff[tussay] = 12 then Kilit_acik if TusBuff[tussay] <> 10 then Clr_TusBuff gosub Beep else gosub Clr_TusBuff endif case 9 if TusBuff[tussay] <> 12 then Clr_TusBuff gosub Beep case 14 if psw.6 = 0 then if TusBuff[tussay] <> 12 then Clr_TusBuff gosub Beep gosub Chk_NewSfrOK if psw.1 or psw.6 then gosub Beep gosub Sifre_Degis gosub Beep gosub Clr_TusBuff else gosub Clr_TusBuff endif endif case 16 if TusBuff[tussay] <> 12 then clr_TusBuff gosub beep gosub Chk_NewSfrOK if psw.6 then gosub Beep gosub Sifre_Degis gosub Beep gosub Clr_TusBuff else gosub Clr_TusBuff endif case else if TusBuff[tussay] = 12 then Clr_TusBuff end select tussay = tussay + 1 return '=============================================================================== Chk_tussay2: select case tussay case 4 if psw.6 then psw.0 = 0 if TusBuff[tussay] = 12 then Kilit_acik if TusBuff[tussay] <> 10 then Clr_TusBuff gosub Beep else gosub Clr_TusBuff endif case 9 if TusBuff[tussay] <> 12 then Clr_TusBuff gosub Beep case 14 if TusBuff[tussay] <> 12 then Clr_TusBuff gosub Beep gosub Chk_NewSfrOK if psw.6 then gosub Beep gosub Sifre_Degis psw.0 = 0 gosub Beep gosub Clr_TusBuff else gosub Clr_TusBuff endif case else if TusBuff[tussay] = 12 then Clr_TusBuff end select tussay = tussay + 1 return '=============================================================================== Reset: for cnt = 0 to 14 TusBuff[cnt] = cnt next low ld1 high buz tussay = 0 psw.0 = 0 psw.1 = 0 psw.6 = 0 say = 0 return '=============================================================================== Hata: say = say + 1 high ld1 low buz pause 200 low ld1 high buz return '=============================================================================== Kilit_acik: if psw.0 = 0 then say = 0 high mtr ' motoru çalıştır High frw ' İleri dön pause Frw_time ' ileri dönme süresi low frw low mtr pause wait_time ' bekleme süresi high mtr ' motoru çalıştır high BCK ' geriye dön pause bck_time ' geriye dönme süresi low BCK low mtr endif gosub Reset return '=============================================================================== Clr_TusBuff: for cnt = 0 to 14 TusBuff[cnt] = cnt next tussay = 0 gosub Ana '=============================================================================== Kilit : psw.0 = 1 low buz high ld1 gosub chk_KEYPAD gosub Kilit end '===============================================================================
Stack overflow executing CALL instruction;
the device is PIC16F628A
What's wrong?
Bookmarks