probleme de connexion port serie et 16f877
Répondre à la discussion
Affichage des résultats 1 à 1 sur 1

probleme de connexion port serie et 16f877



  1. #1
    invite6b4dc7fb

    probleme de connexion port serie et 16f877


    ------

    Bonjour, c'est Firaz, je suis nouveau sur ce forum, j'étudie actuellement la programmation des microcontroleurs 16f877, j'ai trouvé un programme qui assure la liaison serie PC-16f877, mais lorsque je l'éxecute dans l'environnement MPLAB, il m'affiche des erreurs que je n'ai pas pu corriger, pour ceux qui veulent bien m'aider voilà le programme avec un grand merci
    ;============================= ================
    Title "USART TESTER"
    list p=16f877,c=140 ; processor type
    errorlevel 1, -(305)
    #include "p16f877.inc"
    __CONFIG _PWRTE_ON&_HS_OSC&_LVP_OFF&_WD T_OFF

    temp equ 7Fh ;
    ;
    ; -----------
    ; DESCRIPTION
    ; -----------
    ;
    ; Baud Rate = 9600, No Parity, 8 bits & 1 Stop Bit
    ;
    ; -------------
    ; PROGRAM START
    ; -------------
    ;
    org 0 ; startup = 0000H
    clrf STATUS ; bank 0
    goto BootStart
    org 4
    ISR goto 5 ;
    org 5
    ;
    ; --------------------------------------------------
    ; SET UP THE PORTS TO SUIT YOUR CIRCUIT REQUIREMENTS
    ; Mettre en place les ports Pour satisfaire vos exigences circuit
    ; --------------------------------------------------
    ;

    BootStart
    banksel PORTA ; bank0
    movlw b'00000000'
    movwf PORTA
    movlw b'00000000'
    movwf PORTB
    movlw b'01000000'
    movwf PORTC
    movlw b'00000000'
    movwf PORTD
    movlw b'00000000'
    movwf PORTE

    banksel TRISA ; bank1
    movlw b'00000001'
    movwf TRISA
    movlw b'00000000'
    movwf TRISB
    movlw b'11000000' ; set RC6 & RC7 as input
    movwf TRISC
    movlw b'00000000'
    movwf TRISD
    movlw b'11101000'
    movwf TRISE
    movlw b'00000111'
    movwf ADCON1 ; porta inputs = digital not analog
    ;
    ; BAUD RATE SETTINGS
    ;
    ; Baud Values with BRGH = 0
    ; ((20000000/9600)/64)-1 = 32
    ; movlw d'207' ; 1200 baud @ 16 Mhz Fosc +0.16 err
    ; movlw d'103' ; 2400 baud @ 16 Mhz Fosc +0.16 err
    movlw d'25' ; 9600 baud @ 16 Mhz Fosc +0.16 err
    ; movlw d'12' ; 19200 baud @ 16 Mhz Fosc +0.16 err
    ; movlw d'255' ; 1200 baud @ 20 Mhz Fosc +1.73 err
    ; movlw d'129' ; 2400 baud @ 20 Mhz Fosc +0.16 err
    ; movlw d'32' ; 9600 baud @ 20 Mhz Fosc -1.36 err
    ; movlw d'15' ; 19200 baud @ 20 Mhz Fosc +1.73 err

    ; Baud Values with BRGH = 1
    ; ((20000000/9600)/16)-1 = 32
    movlw d'129' ; 9600 baud @ 20 Mhz Fosc +0.16 err
    movwf SPBRG
    movlw b'00100100' ; brgh = 1
    movwf TXSTA ; enable Async Transmission, set brgh
    banksel RCSTA ; bank0
    movlw b'10010000'
    movwf RCSTA ; enable Async Reception
    movf RCREG,w
    movf RCREG,w
    movf RCREG,w ; flush receive buffer
    ;
    ;
    ; ------------------------------------
    ; PROVIDE A SETTLING TIME FOR START UP
    ; Fournir un temps d'établissement pour démarrer
    ; ------------------------------------
    ;
    clrf temp
    Settle
    decfsz temp
    goto Settle

    LWaitCom
    call RecLoop ; wait and read from RS232
    movwf PORTB ; show value for diagnostic purpose
    TxLoop
    nop
    btfss PIR1,TXIF ;xmit buffer empty?
    goto TxLoop ;no, wait

    movwf TXREG

    goto LWaitCom ; no
    ;
    ; ----------------------------
    ; RECEIVE CHARACTER FROM RS232
    ; ----------------------------
    ; This routine does not return until a character is received.
    ; Cette routine ne retourne pas jusqu'à ce qu'un caractère est reçu.

    RecLoop
    nop
    btfss PIR1,RCIF ; check for received data
    ; Vérifier les données reçues
    goto RecLoop
    movf RCREG,w
    return
    end

    -----
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. aide pour PIC 16F877 vers PC via port serie (transfert de données)
    Par invite1c4b6700 dans le forum Électronique
    Réponses: 8
    Dernier message: 08/05/2009, 01h47
  2. probleme de connexion au port
    Par invite952e6095 dans le forum Internet - Réseau - Sécurité générale
    Réponses: 4
    Dernier message: 23/09/2007, 08h23
  3. Port serie sur 16F877 avec CCS
    Par joseph4008 dans le forum Électronique
    Réponses: 7
    Dernier message: 12/07/2006, 17h56
  4. Probleme de dialogue entre VB et le port serie
    Par invite47dfc8ff dans le forum Matériel - Hardware
    Réponses: 4
    Dernier message: 21/04/2006, 16h21
  5. Probleme de dialogue entre VB et le port serie
    Par invite47dfc8ff dans le forum Électronique
    Réponses: 1
    Dernier message: 21/04/2006, 15h12
Découvrez nos comparatifs produits sur l'informatique et les technologies.