Sie sind auf Seite 1von 12

TP6 : Microcontrôleur

Réaliser par encadre par


YOUNESS MZAKI M.hicham
MOHAMADE Chakir
Objectif
L’Objectif de ce TP est d’utilliser les ports d’E \S du PIC
16F84A pour le contrôle des périphériques tel
que :LED ,SWITCH ,afficher
Exercice 1 :
1)Commande d’un afficher 7segments
On voudrait afficher les chiffres décimaux au moyen d’un
afficher 7 segment à l’aide du PORETB DU PIC16F84A.

Programme on MicroC
2)Commande d’un Feu Routier :

Le programma en assembleurs
3)Réalisation d’un jeu de lumière à séquences multiples
Le programme on assembleur

LIST p=16F84A ; Définition de processeur

#include <p16F84A.inc> ; Définitions de variables

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON &


_HS_OSC

;--------------- Déclaration des variables ------------------

cblock 0x00C

i :1

n :1

endc

;--------------- Démarrage sur RESET -----------------------

org 0x000 ; Adresse de départ après reset

goto init ; Adresse 0: initialiser


;--------------- Initialisation ----------------------------

init

bsf STATUS,RP0 ; sélectionner banque 1

clrf TRISB ; PORTB en sortie (banque1)

movlw 0x03 ;

movwf TRISA ; PORTA en entrée(banque1)

clrf TRISB

bcf STATUS,RP0 ; repasser banque 0

;--------------- Programme principal ----------------------

debut

movf PORTA,W

movwf n

movlw 0x00

xorwfn,W

btfss STATUS,Z

goto test2

call progF1

goto debut

test2

movlw 0x01

xorwfn,W
btfss STATUS,Z

goto test3

call progF2

goto debut

test3

movlw 0x02

xorwfn,W

btfss STATUS,Z

goto test4

call progF3

goto debut

test4

movlw 0x03

xorwfn,W

btfss STATUS,Z

goto debut

call progF4

goto debut

end

;-------------------------sous programm1 1--------------------

progF1

bsf portb,7

x1 call tempo
bcf STATUS,C

rlf portb,f

btfss status,c

goto x1

bsf portb,0

x2 call tempo

bcf STATUS,C

rrf portb,f

btfss STATUS,C

goto x2

return

;-------------------------sous programm1 2--------------------

progF2

clrf i

movlw 0xAA

movwf portb

rbt call tempo

incf i,f

comf portb,f

movlw 0x0a

xorwfi,W

btfss STATUS,Z
goto rbt

return

;-------------------------sous programm1 3--------------------

progF4

movlw b'11000000'

movwf portb

lolo

call tempo

bcf STATUS,C

rrf portb,f

btfss status,c

goto lolo

movlw 0x03

movwf portb

zozo

call tempo

bcf STATUS,C

rlf portb,f

btfss STATUS,C

goto zozo

return
;--------------- Programme principal ----------------------

progF3

clrf portb

P3 movf i,W

CALL sq

MOVWF PORTB

INCF i,F

MOVLW 0X07

XORWF i,W

BTFSS STATUS,Z

GOTO P3

return

;-------------------------sous programm--------------------

sq

ADDWF PCL,F
RETLW 0X81

RETLW 0XC3

RETLW 0XE7

RETLW 0XFF

RETLW 0XE7

RETLW 0XC3

RETLW 0X81

Return

Conclusion
1. Pour écrire un programme on a besoin d’un éditeur de texte et un
compilateur
2. Il est obligatoire de définir la librairie du PIC utilisé
3. Il est obligatoire de faire « ; » à la fin de chaque instruction
4. « // » pour écrire un commentaire

Das könnte Ihnen auch gefallen