IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Autres architectures Assembleur Discussion :

Modif code pour PIC 16F84A


Sujet :

Autres architectures Assembleur

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2012
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Modif code pour PIC 16F84A
    Suite au montage d'une platine électronique de commande de huit relais par code DTMF avec un GSM (tout fonctionne), mes connaissances en programmation étant hélas très limitées, voici mon problème : Comment modifier le temps (trop court) qui permet d'entrer le code de sécurité + le code relais (ex. *1234 11# ) ?

    Ci-joint le fichier code ASM. Merci d'avance pour vos réponses.

    Fichier pour pic 16f84a

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    ; dtmf.asm - tone decoder with relay control. 
     
    ; reads output from an 8870 DTMF decoder and controls a bank of relays. 
    ; 4 digit security code (abcd) precedes all commands 
    ; Code sequences "*abcd11#" through to "*abcd18#" turn on the corresponding relay 
    ; code sequence "*abcd10#" turns on all relays 
    ; Code sequences "*abcd21#" through to "*abcd28#" turn off the corresponding relay 
    ; Code sequence "*abcd20#" turns off all relays 
    ; Codes "*abcd?9#" through "*abcd?D#" are ignored.\ 
    ; Note "oa" is used for "0" in security code not"00" 
     
    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 got_2 
    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 got_12 
    goto got_13 
    goto got_14 
    goto got_15 
    goto got_16 
    goto got_17 
    goto got_18 
    goto decode 
    goto got_10 
    goto decode ;* 
    goto decode ;# 
    goto decode ;5A 
    goto decode ;5B 
    goto decode ;5C (mf code 1111) 
     
    got_10 movlw B'11111111' ;all outputs on 
    movwf relays 
    goto get_# 
     
     
    got_11 bsf relays,0 ;set output 1 on 
    goto get_# 
     
    got_12 bsf relays,1 ;set output 2 on 
    goto get_# 
     
    got_13 bsf relays,3 ;set output 3 on 
    goto get_# 
     
    got_14 bsf relays,2 ;set output 4 on 
    goto get_# 
     
    got_15 bsf relays,5 ;set output 5 on 
    goto get_# 
     
    got_16 bsf relays,4 ;set output 6 on 
    goto get_# 
     
    got_17 bsf relays,6 ;set output 7 on 
    goto get_# 
     
    got_18 bsf relays,7 ;set output 8 on 
    goto get_# 
     
     
    ; to reach here, the tone sequence "*<numa><numb><numc><numd>2" has been found, now decode request 
    ; according to the next 2 tones but don't action it until a "#" is seen. 
     
    got_2 call wait_no_strobe 
    call wait_strobe ;wait for sixth 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_21 
    goto got_22 
    goto got_23 
    goto got_24 
    goto got_25 
    goto got_26 
    goto got_27 
    goto got_28 
    goto decode 
    goto got_20 
    goto decode ;* 
    goto decode ;# 
    goto decode ;5A 
    goto decode ;5B 
    goto decode ;5C (mf code 1111) 
     
    got_20 movlw B'0000000' 
    movwf relays ;set all outputs off 
    goto get_# 
     
     
    got_21 bcf relays,0 ;set output 1 off 
    goto get_# 
     
    got_22 bcf relays,1 ;set output 2 off 
    goto get_# 
     
    got_23 bcf relays,3 ;set output 3 off 
    goto get_# 
     
    got_24 bcf relays,2 ;set output 4 off 
    goto get_# 
     
    got_25 bcf relays,5 ;set output 5 Off 
    goto get_# 
     
    got_26 bcf relays,4 ;set output 6 Off 
    goto get_# 
     
    got_27 bcf relays,6 ;set output 7 Off 
    goto get_# 
     
    got_28 bcf relays,7 ;set output 8 Off 
    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 
     
    retlw 'v' 
    retlw '1' 
    retlw '.' 
    retlw '3' 
    retlw '.' 
    retlw 'W' 
    retlw 'W' 
    retlw '2' 
    retlw 'R' 
    retlw ' ' 
    retlw 'm' 
    retlw 'a' 
    retlw 'y' 
    retlw '2' 
    retlw '0' 
    retlw '0' 
    retlw '0' 
     
    end

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2011
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2011
    Messages : 9
    Points : 9
    Points
    9
    Par défaut
    C'est cntdown qui contrôle le timeout sur la saisie du code. Il est chargé avec H'54' (= 84 en décimal) à la ligne 78.
    Il suffit d'augmenter cette valeur. La valeur max est 256 = H'00' qui devrait donner un timeout de 21.3 s si on a 7 s avec H'54'.

Discussions similaires

  1. [XL-2010] Modification code pour comparer minuscule/majuscule, accent/sans accent
    Par jgresse1025 dans le forum Macros et VBA Excel
    Réponses: 68
    Dernier message: 08/04/2015, 15h20
  2. [XL-2007] Modification code pour Excel en Plein Ecran
    Par cathodique dans le forum Macros et VBA Excel
    Réponses: 7
    Dernier message: 30/12/2013, 10h39
  3. débutante : place du code pour modif affichage
    Par evevev dans le forum IGN API Géoportail
    Réponses: 17
    Dernier message: 02/04/2010, 17h54
  4. modification Code pour passer un exe en dll
    Par ehkhalid dans le forum C++
    Réponses: 4
    Dernier message: 23/01/2010, 10h38
  5. Réponses: 3
    Dernier message: 26/06/2008, 10h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo