Pic 16F877A configuration port analogique

sabri125 Messages postés 2 Date d'inscription   Statut Membre Dernière intervention   -  
sabri125 Messages postés 2 Date d'inscription   Statut Membre Dernière intervention   -
bonsoir

je veu programmer un pic16f877A en assembleur ...qui peu m'aider svp
jai 2 entrés analogique RA0 et RA1 ET 2 sorties RB0 et RB1
je veux une boue de programme avec le configuration de convertisseur can qui compare entre RA0 et RA1 et met a 1 RB0 si RA0>RA1 si non RB1 a 1....???c urgent svp merci

1 réponse

  1. sabri125 Messages postés 2 Date d'inscription   Statut Membre Dernière intervention   1
     
    voila un programme d'essai mai il ne fonctionne pas ..qui peu m'aider de le corriger merci....
    LIST p=16F877A
    #include <P16F877A.INC>

    ;;;;;;;;;;;;;;PAGES DE TRAVAIL ;;;;;;;;;;;;;;;;;;;;;;;;;
    BANK0 MACRO
    BCF STATUS,RP0
    BCF STATUS,RP1
    ENDM
    BANK1 MACRO
    BSF STATUS,RP0
    BCF STATUS,RP1
    ENDM
    BANK2 MACRO
    BCF STATUS,RP0
    BSF STATUS,RP1
    ENDM
    BANK3 MACRO
    BSF STATUS,RP0
    BSF STATUS,RP1
    ENDM

    cblock 0x20
    count,lc1, lc2;
    endc
    N1 EQU 0X21
    N2 EQU 0X22
    ; Vector for normal start up.
    org 0
    goto start

    org 4
    goto inthlr

    start ;clrw
    BANK1
    movlw 0xFF
    movwf TRISA
    movlw 0x00
    movwf TRISB
    BANK1
    MOVLW B'00000000'
    MOVWF ADCON1
    BANK0
    movlw B'11010000'
    movwf ADCON0
    MOVLW 0X01
    call swait
    BANK0
    do_conv bsf ADCON0,GO
    btfsc ADCON0,GO

    BANK1
    MOVF ADRESH,W
    MOVWF N2
    call SELECT1
    call SELECT2

    MOVF N2,W
    CALL DEFF1
    CALL DEFF2
    goto do_conv
    inthlr retfie
    ;;;;;;;;;;;;;;;;fin d'intereption..;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;declaration de procedur.....;;;;
    SELECT1 BANK0
    ; BCF ADCON0,CHS0
    ; BCF ADCON0,CHS1
    ; BCF ADCON0,CHS2
    movf ADRESL,W
    movwf N1
    RETURN

    BANK0
    SELECT2 BSF ADCON0,CHS0
    BCF ADCON0,CHS1
    BCF ADCON0,CHS2
    BSF STATUS,RP0
    movf ADRESL,W
    MOVWF N2
    RRF N2,F
    RRF N2,F
    RETURN

    DEFF1 ; MOVF ADRESH,W
    ; MOVF N2,W
    SUBWF N1,W
    s1 BTFSC STATUS,Z
    GOTO start
    BTFSC STATUS,C
    GOTO s1

    BSF PORTB,4

    return

    DEFF2 ; MOVF ADRESH,W
    ; MOVF N2,W
    SUBWF N2,W
    s2 BTFSC STATUS,Z
    GOTO start
    BTFSC STATUS,C
    GOTO s2
    ;call swait
    BSF PORTB,1

    return
    GOTO start
    ; -------------------------------------------------------------------------------
    ; Wait function
    ; -------------
    swait movwf lc2
    _sw2 movlw 0x02
    movwf lc1
    _sw3 nop
    decfsz lc1,f
    goto _sw3
    decfsz lc2,f
    goto _sw2
    return

    END
    1