Dtmf ile kontrol devresi

seko74

Üye
Katılım
29 Ara 2013
Mesajlar
4
Puanları
1
arkadaşlar elimde dtmf ile kontrol devresi var asm kodunda göreceğiniz gibi kod doğru yazılırsa roleyi çekiyor ancak ben bu rolenin 5 saniye sonra kapatma kodu olmadan bırakmasını yani otomatik olarak bırakmasını istiyorum asm ye nasıl bir ek yapmam gerek.

asm kodu
-----------
Kod:
    list    p=16f84a

    include "p16f84a.inc"

    __FUSES _CP_OFF & _XT_OSC  & _WDT_OFF & _PWRTE_ON



OPTREG    equ    01

TRIS_A    equ    05

TRIS_B    equ    06



relays    equ    10

mfcode    equ    11

cntdown    equ    12

timeout    equ    13

slocnt1    equ    14

slocnt2    equ    15

numa    equ    16

numb    equ    17

numc    equ    18

numd    equ     19



    org 0000            ;tell assembler to start at 000H



init    goto start



    org 0004            ;interrupt vector



rtc_interrupt

    decfsz slocnt1,F        ;decrement 1st prescaler

    goto rtc_int_1

    decfsz slocnt2,F        ;decrement 2nd prescaler

    goto rtc_int_1

    bcf relays,4            ;turn relay 6 off

    bcf PORTB,4

rtc_int_1

    decfsz cntdown,F        ;count down and skip next if = 0

    goto counting            ;still counting if not reached zero

    bsf timeout,0            ;set timed out bit

    bcf INTCON,2            ;clear interrupt flag

    retfie                ;return



counting

    bcf timeout,0            ;clear timed out bit

    bcf INTCON,2            ;clear interrupt flag

    retfie                ;return



; subroutines



wait_strobe

    btfsc timeout,0            ;see if timed out

    goto set_z            ;set Z flag if timeout ocurred

    btfss PORTA,4            ;see if Strobe is active on RA4

    goto wait_strobe        ;loop until it is

    movfw PORTA            ;retreive the code from the 8870

    movwf mfcode            ;store it in mfcode

    bcf mfcode,4            ;ensure strobe isn't seen as data

    bcf STATUS,2            ;return with Z=0 if tone decoded

    return



set_z    bsf STATUS,2            ;return with Z=1 if timed out waiting

    return



wait_no_strobe

    btfsc PORTA,4            ;see if strobe is active on RA4

    goto wait_no_strobe        ;loop until it isn't

    return



start_timer

    movlw H'54'            ;software prescaler for 7 seconds

    movwf cntdown

    return



; Start of setup and decode routines:



start    movlw B'00100000'        ;select register page 1

    movwf STATUS



    clrf TRIS_B            ;set all port B pins to output mode

    movlw B'00011111'        ;set all port A pins to input mode

    movwf TRIS_A

    movlw B'10000111'

    movwf OPTREG            ;sets:     pull-up on port B OFF

                    ;    RTCC counts internal clock

                    ;    prescaler connected to RTCC

                    ;    prescaler divides by 256

                    ;    (other bits unimportant)

    clrw                ;clear the working register

    movwf STATUS            ;switch back to register page 0

    clrf PORTB            ;all outputs off

    clrf relays

    clrf timeout

    movlw B'10100000'

    movwf INTCON            ;global and RTCC interrupts enabled



set_sec    movlw H'01'            ;put the 4 access codes into memory

    movwf numa            ;note for a 0 the hex is H'0A'

    movlw H'02'

    movwf numb

    movlw H'03'

    movwf numc

    movlw H'04'

    movwf numd



decode    call wait_no_strobe        ;start running when no tone present

    clrf timeout            ;set timeout condition until later

    call wait_strobe        ;wait for a tone to be received

    movlw H'0B'            ;0B is the code for DTMF "*"

    subwf mfcode,W            ;set zero flag if "*" was received

    btfsc STATUS,2            ;skip next if it was not a "*"

    goto got_star

    goto decode            ;look for another one



got_star

    call start_timer        ;start time-out timer

    call wait_no_strobe        ;wait for second tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numa,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_A

    goto get_#



got_A    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numb,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_B

    goto get_#



got_B    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numc,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_C

    goto get_#



got_C    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numd,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_D

    goto get_#





got_D    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

 

    movlw H'01'

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_1

 

    movlw H'02'

    subwf mfcode,W                  ;set zero flag if second tone was 0

    btfsc STATUS,2            ;skip next if it was not a 0

    goto get_#            ;wait for # to end invalid sequence



; to reach here, the tone sequence "*<numa><numb><numc><numd>1" has been found, now decode request

; according to the next 2 tones but don't action it until a "#" is seen.



got_1    call wait_no_strobe

    call wait_strobe        ;wait for third tone

    btfsc STATUS,2            ;abort if timed out

    goto decode



    call wait_no_strobe        ;wait for tone to finish

    movf mfcode,W            ;pick up keyed digit

    addwf PCL,F            ;jump ahead to vector

    goto decode            ;5D (mf code 0000)

    goto got_11

    goto decode            ;*

    goto decode            ;#

    goto decode            ;5A

    goto decode            ;5B

    goto decode            ;5C (mf code 1111)



got_11    bsf relays,0            ;set output 1 on

    goto get_#







get_#    call wait_strobe        ;wait for 7th tone

    btfsc STATUS,2            ;abort if timed out

    goto decode



    movlw H'0C'            ;0C is the DTMF code for "#"

    subwf mfcode,W            ;if # received set Z flag

    btfsc STATUS,2            ;skip next if not a #

    goto got_#

    call wait_no_strobe

    goto get_#            ;only # is valid, loop until found

                            ;or timeout

     

got_#   call wait_no_strobe        ;wait for the tone to finish

    movfw relays            ;use the "relays" variable to set RB

    movwf PORTB

    goto decode            ;all done, check for new sequence



 

    end
 
Moderatör tarafında düzenlendi:

alarmko

Üye
Katılım
14 Ocak 2009
Mesajlar
416
Puanları
8
boş cevrimin döndügü kısımda röle çekilimi diye kontrol yapacaksın.eger role cekili ise 5 saniyelik boş dongü yazıp,döngünün bitişinde röleyi bıraktıracaksın.
Benim gördügüm kadarıyla:

COUNTER1 equ 20 //ekle
COUNTER2 equ 21 //ekle
org 0000 ;tell assembler to start at 000H =====>SATIRININ USTUNE yukardaki iki satırı ekle
Kod:
decode    call wait_no_strobe        ;start running when no tone present



    clrf timeout            ;set timeout condition until later



    call wait_strobe        ;wait for a tone to be received



    movlw H'0B'            ;0B is the code for DTMF "*"



    subwf mfcode,W            ;set zero flag if "*" was received



    btfsc STATUS,2            ;skip next if it was not a "*"



    goto got_star



//*************bu kısım sonradan eklendi************************************

   btfss relays,0   // role cekili ise asagı dallan

   goto decode

//***5 saniye bekleme kısmı

clrf COUNTER1

  movlw  0x20  // bu degeri deneyerek degistir(sure için)

  movwf  COUNTER2



bosdongu   nop               // 5 sanıye bekleme için bos dongu yapıyoruz

                    decfsz COUNTER1,f

                     goto   bosdongu

                     decfsz COUNTER2,f

                     goto   bosdongu



                      bcf relays,0  //roleyi bıraktır



//*************ekleme sonu***************************************************

    goto decode            ;look for another one
işallah calısır.
kolay gelsin.
Eger assambler ile ugrasıyorsan kendini biraz daha geliştirdikten sonra arm ye geçmeni öneririm
 
Moderatör tarafında düzenlendi:
Konu Sah
S

seko74

Üye
Katılım
29 Ara 2013
Mesajlar
4
Puanları
1
tşkler akşam derleyip deneyeceğim umarım çalışır
hocam kodu ekledim ancak aşağıdaki hataları verdi dosyalar ekte.
 

Ekli dosyalar

  • 6.8 KB Görüntüleme: 1
Son düzenleme:

alarmko

Üye
Katılım
14 Ocak 2009
Mesajlar
416
Puanları
8
Kod:
list    p=16f84a

    include "p16f84a.inc"

    __FUSES _CP_OFF & _XT_OSC  & _WDT_OFF & _PWRTE_ON



OPTREG    equ    01

TRIS_A    equ    05

TRIS_B    equ    06



relays    equ    10

mfcode    equ    11

cntdown    equ    12

timeout    equ    13

slocnt1    equ    14

slocnt2    equ    15

numa    equ    16

numb    equ    17

numc    equ    18

numd    equ     19

COUNTER1 equ 20

COUNTER2 equ 21

    org 0000            ;tell assembler to start at 000H



init    goto start



    org 0004            ;interrupt vector



rtc_interrupt

    decfsz slocnt1,F        ;decrement 1st prescaler

    goto rtc_int_1

    decfsz slocnt2,F        ;decrement 2nd prescaler

    goto rtc_int_1

    bcf relays,4            ;turn relay 6 off

    bcf PORTB,4

rtc_int_1

    decfsz cntdown,F        ;count down and skip next if = 0

    goto counting            ;still counting if not reached zero

    bsf timeout,0            ;set timed out bit

    bcf INTCON,2            ;clear interrupt flag

    retfie                ;return



counting

    bcf timeout,0            ;clear timed out bit

    bcf INTCON,2            ;clear interrupt flag

    retfie                ;return



; subroutines



wait_strobe

    btfsc timeout,0            ;see if timed out

    goto set_z            ;set Z flag if timeout ocurred

    btfss PORTA,4            ;see if Strobe is active on RA4

    goto wait_strobe        ;loop until it is

    movfw PORTA            ;retreive the code from the 8870

    movwf mfcode            ;store it in mfcode

    bcf mfcode,4            ;ensure strobe isn't seen as data

    bcf STATUS,2            ;return with Z=0 if tone decoded

    return



set_z    bsf STATUS,2            ;return with Z=1 if timed out waiting

    return



wait_no_strobe

    btfsc PORTA,4            ;see if strobe is active on RA4

    goto wait_no_strobe        ;loop until it isn't

    return



start_timer

    movlw H'54'            ;software prescaler for 7 seconds

    movwf cntdown

    return

 

; Start of setup and decode routines:



start    movlw B'00100000'        ;select register page 1

    movwf STATUS



    clrf TRIS_B            ;set all port B pins to output mode

    movlw B'00011111'        ;set all port A pins to input mode

    movwf TRIS_A

    movlw B'10000111'

    movwf OPTREG            ;sets:     pull-up on port B OFF

                    ;    RTCC counts internal clock

                    ;    prescaler connected to RTCC

                    ;    prescaler divides by 256

                    ;    (other bits unimportant)

    clrw                ;clear the working register

    movwf STATUS            ;switch back to register page 0

    clrf PORTB            ;all outputs off

    clrf relays

    clrf timeout

    movlw B'10100000'

    movwf INTCON            ;global and RTCC interrupts enabled



set_sec    movlw H'01'            ;put the 4 access codes into memory

    movwf numa            ;note for a 0 the hex is H'0A'

    movlw H'02'

    movwf numb

    movlw H'03'

    movwf numc

    movlw H'04'

    movwf numd



decode    call wait_no_strobe        ;start running when no tone present

    clrf timeout            ;set timeout condition until later

    call wait_strobe        ;wait for a tone to be received

    movlw H'0B'            ;0B is the code for DTMF "*"

    subwf mfcode,W            ;set zero flag if "*" was received

    btfsc STATUS,2            ;skip next if it was not a "*"

    goto got_star

    btfss relays,0 

        goto decode







clrf COUNTER1



  movlw  0x20



  movwf  COUNTER2







bosdongu   nop           



                    decfsz COUNTER1,f



                     goto   bosdongu



                     decfsz COUNTER2,f



                     goto   bosdongu







                      bcf relays,0



        goto decode            ;look for another one



got_star

    call start_timer        ;start time-out timer

    call wait_no_strobe        ;wait for second tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numa,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_A

    goto get_#



got_A    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numb,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_B

    goto get_#



got_B    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numc,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_C

    goto get_#



got_C    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

    movf numd,W

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_D

    goto get_#





got_D    call wait_no_strobe        ;wait for third tone

    call wait_strobe

    btfsc STATUS,2            ;abort if timed out

    goto decode

  

    movlw H'01'

    subwf mfcode,W                  ;set zero flag if second tone was 1

    btfsc STATUS,2            ;skip next if it was not a 1

    goto got_1

  

    movlw H'02'

    subwf mfcode,W                  ;set zero flag if second tone was 0

    btfsc STATUS,2            ;skip next if it was not a 0

    goto get_#            ;wait for # to end invalid sequence



; to reach here, the tone sequence "*<numa><numb><numc><numd>1" has been found, now decode request

; according to the next 2 tones but don't action it until a "#" is seen.



got_1    call wait_no_strobe

    call wait_strobe        ;wait for third tone

    btfsc STATUS,2            ;abort if timed out

    goto decode



    call wait_no_strobe        ;wait for tone to finish

    movf mfcode,W            ;pick up keyed digit

    addwf PCL,F            ;jump ahead to vector

    goto decode            ;5D (mf code 0000)

    goto got_11

    goto decode            ;*

    goto decode            ;#

    goto decode            ;5A

    goto decode            ;5B

    goto decode            ;5C (mf code 1111)



got_11    bsf relays,0            ;set output 1 on

    goto get_#







get_#    call wait_strobe        ;wait for 7th tone

    btfsc STATUS,2            ;abort if timed out

    goto decode



    movlw H'0C'            ;0C is the DTMF code for "#"

    subwf mfcode,W            ;if # received set Z flag

    btfsc STATUS,2            ;skip next if not a #

    goto got_#

    call wait_no_strobe

    goto get_#            ;only # is valid, loop until found

                            ;or timeout

      

got_#   call wait_no_strobe        ;wait for the tone to finish

    movfw relays            ;use the "relays" variable to set RB

    movwf PORTB

    goto decode            ;all done, check for new sequence



  

    end
yav arkadas birazda gayret gosterin,hatanın oldugu satırlar acıklama satırlarıymıs, // ları silince duzeldi.
derleme tamam ancak programın ne iş yapacagına emin degilim.senin düzenleme yapman gerekebilir.
 
Moderatör tarafında düzenlendi:
Konu Sah
S

seko74

Üye
Katılım
29 Ara 2013
Mesajlar
4
Puanları
1
üstat öncelikle cevabın için tşk.ler.
ancak ben bu işi iyi biliyorum demedim ayrıca zaten bilsem yardım istemezdim. herneyse derledim pic e yazdım fakat fark yok. doğru kodu yazınca role çekiyor buraya kadar sorun yok kodun devamıda var fakat kapatma şifresi girilince kapatıyordu ben şifre girerek kapatmak istemiyorum role aktif olunca 5 sn. sonra kendisi kapansın istiyorum. yinede ilgi ve yardımına minnettarım. kolay gelsin.
 

by lent

Yönetici
Yönetici
Yönetici
Katılım
21 Nis 2009
Mesajlar
9,500
Puanları
2,508

alarmko

Üye
Katılım
14 Ocak 2009
Mesajlar
416
Puanları
8
assambler i iyi kötü bildiginizi veya biraz anladıgınızı varsaymıstım,o yüzden üstünkörü acıklama yapıp gecmistim.kusura bakma.
önceki yazdıgımda süre cok kısa imiş,6ms de roleyi bıraktırıyormus.içiçe bir tane daha bos dongü ekleyince süre uzuyor.birde cihazınızda kac mhz lik kristal kullandıgınız bilmiyorum.4 mhz lik kristal için
bosdongu NOP
decfsz COUNTER3,F
goto bosdongu

decfsz COUNTER1,f
goto bosdongu
decfsz COUNTER2,f
goto bosdongu



bcf relays,0

goto decode ;look for another one
olarak düzeltin,takriben 8 sn sonra rölenin bırakması lazım.
süreyi degistirmek için movlw 0x20 deki 20 rakamı ile oynayın.
birde en üste COUNTER3 equ 22 tanımlaması yapmayı unutmayın.
birde böyle deneyin bakalım ne olacak.
 
Konu Sah
S

seko74

Üye
Katılım
29 Ara 2013
Mesajlar
4
Puanları
1
kodu anlattığınız gibi değiştirdim umarım yanlışlık yoktur ancak yine olmadı role çekiyor ama süreyle oyamama rağmen bırakmıyor
Kod:
    list    p=16f84a

    include "p16f84a.inc"

    __FUSES _CP_OFF & _XT_OSC  & _WDT_OFF & _PWRTE_ON



OPTREG   equ     01

TRIS_A   equ     05

TRIS_B   equ     06



relays  equ    10

mfcode  equ    11

cntdown equ    12

timeout equ    13

slocnt1 equ    14

slocnt2 equ    15

numa    equ    16

numb    equ    17

numc    equ    18

numd    equ    19



COUNTER1 equ 20

COUNTER2 equ 21

COUNTER3 equ 22       

      

        org 0000            ;tell assembler to start at 000H



init    goto start



        org 0004            ;interrupt vector



rtc_interrupt



        decfsz slocnt1,F                ;decrement 1st prescaler

        goto rtc_int_1

        decfsz slocnt2,F                ;decrement 2nd prescaler

        goto rtc_int_1

        bcf relays,4                    ;turn relay 6 off

        bcf PORTB,4

rtc_int_1

        decfsz cntdown,F                ;count down and skip next if = 0

        goto counting                   ;still counting if not reached zero

        bsf timeout,0                   ;set timed out bit

        bcf INTCON,2                    ;clear interrupt flag

        retfie                          ;return



counting

        bcf timeout,0                   ;clear timed out bit

        bcf INTCON,2                    ;clear interrupt flag

        retfie                          ;return



; subroutines



wait_strobe

        btfsc timeout,0                 ;see if timed out

        goto set_z                      ;set Z flag if timeout ocurred

        btfss PORTA,4                   ;see if Strobe is active on RA4

        goto wait_strobe                ;loop until it is

        movfw PORTA                     ;retreive the code from the 8870

        movwf mfcode                    ;store it in mfcode

        bcf mfcode,4                    ;ensure strobe isn't seen as data

        bcf STATUS,2                    ;return with Z=0 if tone decoded

        return



set_z   bsf STATUS,2                    ;return with Z=1 if timed out waiting

        return



wait_no_strobe

        btfsc PORTA,4                   ;see if strobe is active on RA4

        goto wait_no_strobe             ;loop until it isn't

        return



start_timer

        movlw H'54'                     ;software prescaler for 7 seconds

        movwf cntdown

        return





; Start of setup and decode routines:



start   movlw B'00100000'               ;select register page 1

        movwf STATUS



        clrf TRIS_B                     ;set all port B pins to output mode

        movlw B'00011111'               ;set all port A pins to input mode

        movwf TRIS_A

      

        movlw B'10000111'

        movwf OPTREG                    ;sets:     pull-up on port B OFF

                                        ;    RTCC counts internal clock

                                        ;    prescaler connected to RTCC

                                        ;    prescaler divides by 256

                                        ;    (other bits unimportant)

        clrw                            ;clear the working register

        movwf STATUS                    ;switch back to register page 0

        clrf PORTB                      ;all outputs off

        clrf relays

        clrf timeout

        movlw B'10100000'

        movwf INTCON                    ;global and RTCC interrupts enabled



set_sec movlw H'01'                     ;put the 4 access codes into memory

        movwf numa                      ;note for a 0 the hex is H'0A'

        movlw H'02'

        movwf numb

        movlw H'03'

        movwf numc

        movlw H'04'

        movwf numd



decode  call wait_no_strobe             ;start running when no tone present

        clrf timeout                    ;set timeout condition until later

        call wait_strobe                ;wait for a tone to be received

        movlw H'0B'                     ;0B is the code for DTMF "*"

        subwf mfcode,W                  ;set zero flag if "*" was received

        btfsc STATUS,2                  ;skip next if it was not a "*"

        goto got_star

      

        btfss relays,0



        goto decode



        clrf COUNTER1



        movlw  0x20

      

        movwf  COUNTER2



bosdongu   nop

      

        decfsz COUNTER3,F



        goto bosdongu

      

        decfsz COUNTER1,f



        goto   bosdongu



        decfsz COUNTER2,f



        goto   bosdongu



        bcf relays,0

      

        goto decode                     ;look for another one



got_star

        call start_timer                ;start time-out timer

        call wait_no_strobe             ;wait for second tone

        call wait_strobe

        btfsc STATUS,2                  ;abort if timed out

        goto decode

        movf numa,W

        subwf mfcode,W                  ;set zero flag if second tone was 1

        btfsc STATUS,2                  ;skip next if it was not a 1

        goto got_A

        goto get_#



got_A   call wait_no_strobe             ;wait for third tone

        call wait_strobe

        btfsc STATUS,2                  ;abort if timed out

        goto decode

        movf numb,W

        subwf mfcode,W                  ;set zero flag if second tone was 1

        btfsc STATUS,2                  ;skip next if it was not a 1

        goto got_B

        goto get_#

 

got_B   call wait_no_strobe             ;wait for third tone

        call wait_strobe

        btfsc STATUS,2                  ;abort if timed out

        goto decode

        movf numc,W

        subwf mfcode,W                  ;set zero flag if second tone was 1

        btfsc STATUS,2                  ;skip next if it was not a 1

        goto got_C

        goto get_#







got_C   call wait_no_strobe             ;wait for third tone

        call wait_strobe

        btfsc STATUS,2                  ;abort if timed out

        goto decode

        movf numd,W

        subwf mfcode,W                  ;set zero flag if second tone was 1

        btfsc STATUS,2                  ;skip next if it was not a 1

        goto got_D

        goto get_#





got_D   call wait_no_strobe             ;wait for third tone

        call wait_strobe

        btfsc STATUS,2                  ;abort if timed out

        goto decode



        movlw H'01'

        subwf mfcode,W                  ;set zero flag if second tone was 1

        btfsc STATUS,2                  ;skip next if it was not a 1

        goto got_1



        movlw H'02'

        subwf mfcode,W                  ;set zero flag if second tone was 0

        btfsc STATUS,2                  ;skip next if it was not a 0

        goto get_#                      ;wait for # to end invalid sequence







; to reach here, the tone sequence "*<numa><numb><numc><numd>1" has been found, now decode request

; according to the next 2 tones but don't action it until a "#" is seen.



got_1   call wait_no_strobe

        call wait_strobe                ;wait for third tone

        btfsc STATUS,2                  ;abort if timed out

        goto decode



        call wait_no_strobe             ;wait for tone to finish

        movf mfcode,W                   ;pick up keyed digit

        addwf PCL,F                     ;jump ahead to vector

        goto decode                     ;5D (mf code 0000)

        goto got_11

        goto decode                     ;*

        goto decode                     ;#

        goto decode                     ;5A

        goto decode                     ;5B

        goto decode                     ;5C (mf code 1111)



got_11  bsf relays,0                    ;set output 1 on

        goto get_#



get_#   call wait_strobe               ;wait for 7th tone

        btfsc STATUS,2                 ;abort if timed out

        goto decode



        movlw H'0C'                    ;0C is the DTMF code for "#"

        subwf mfcode,W                 ;if # received set Z flag

        btfsc STATUS,2                 ;skip next if not a #

        goto got_#

        call wait_no_strobe

        goto get_#                     ;only # is valid, loop until found



                                       ;or timeout



got_#   call wait_no_strobe            ;wait for the tone to finish

        movfw relays                   ;use the "relays" variable to set RB

        movwf PORTB

        goto decode            ;all done, check for new sequence





    end
 
Moderatör tarafında düzenlendi:

Sponsor Bağlantı

Forum istatistikleri

Konular
105,984
Mesajlar
746,614
Kullanıcılar
393,881
Son üye
yurdakul1985

Yeni konular

Üst