Professional Documents
Culture Documents
M.CATTOEN
Janvier 2003
-0-
TABLE DES MATIERES
INTRODUCTION..................................................................................................................................................3
CHAPITRE I..........................................................................................................................................................5
INTRODUCTION..................................................................................................................................................5
-1-
II-1-4-3 Mode direct ..........................................................................................................................................49
II-1-4-4 Mode indirect .......................................................................................................................................49
II-1-4-5 Mode indexé .........................................................................................................................................49
II-1-4-6 Mode relatif ..........................................................................................................................................49
II-1-4-7 Opérations spéciales ............................................................................................................................50
II-2 L'INTERFACE PARALLELE 8255 (PROGRAMMABLE PERIPHERAL INTERFACE PPI) ........53
II-2-1 PRESENTATION DU CIRCUIT ..........................................................................................................................53
II-2-1 MODES DE FONCTIONNEMENT ......................................................................................................................54
II-3 LES TRANSMISSIONS SERIE..................................................................................................................57
II-3-1 GENERALITES ...............................................................................................................................................57
II-3-1-1 Communications asynchrones..............................................................................................................57
II-3-1-2 Communications synchrones................................................................................................................58
II-3-2 EXEMPLE D'INTERFACE SERIE : L'ACIA MC 6850........................................................................................59
II-3-2-1 Présentation du circuit (Fig.II-3-2)......................................................................................................59
II-3-2-2 Fonctionnement....................................................................................................................................61
CHAPITRE III.....................................................................................................................................................65
III-1 DESCRIPTION DU MATERIEL DE TRAVAUX PRATIQUES................................................................65
III-2 DESCRIPTION DE LA CARTE MICR0CONTROLEUR 8051..................................................................66
III-3 DESCRIPTION DE LA PLAQUETTE DE TP-CNA...................................................................................67
III-4 TRAVAIL A REALISER..............................................................................................................................69
III-4-1 Utilisation de l’environnement MUVISION ...........................................................................................69
III-4-2 Exercices de programmation..................................................................................................................70
III-4-3 Sortie d’informations..............................................................................................................................71
III-4-4 Conversion analogique-numérique ........................................................................................................72
III-4-5 Acquisition de données...........................................................................................................................73
BIBLIOGRAPHIE...............................................................................................................................................75
ANNEXES ............................................................................................................................................................76
-2-
INTRODUCTION
L'apparition des microprocesseurs date du début des années 1970. A cette époque,
deux événements favorables sont apparus :
- la vitesse de fonctionnement,
- la largeur des mots traités (8, 16, 32, 64 bits),
- le nombre et la complexité des opérations réalisables.
-3-
"microcontrôleur". Ce type de composant s’est répandu dans un très grand nombre de
domaines (télécommunications, télévision, électro-ménager, hifi...).
Le troisième chapitre présente le matériel utilisé en travaux pratiques ainsi que les
différents programmes d’application à réaliser.
-4-
CHAPITRE I
INTRODUCTION
I-1 FONCTION MEMOIRE
I-1-1 Définitions
I-1-2 Organisation des mémoires
I-1-2-1 Organisation par bits
I-1-2-2 Organisation par mots
I-1-3 Classification des mémoires
I-1-3-1 Mémoires mortes
I-1-3-2 Mémoires vives
I-1-3-3 Association de mémoires
I-1-3-4 Autres types de mémoire
INTRODUCTION
La plus petite quantité d'information (unité) est appelée BIT. Elle correspond à la
notion de "variable booléenne ou binaire" qui ne peut prendre que les valeurs 0 ou 1.
E R
courant
Emetteur Récepteur
Figure I-1-1
-5-
Si l'on considère 2 sous-ensembles reliés par un bus, l'information peut circuler dans
un sens (bus unidirectionnel) ou dans les 2 sens (bus bidirectionnel). Dans le premier cas, il
s'agit de la liaison entre un émetteur et un récepteur (Fig.I-1-2-a). Dans le second, chaque
sous-ensemble peut être configuré soit en émetteur, soit en récepteur (Fig.I-1-2-b). Ici, une
ligne supplémentaire est nécessaire pour fixer le sens des échanges. Elle commande le
multiplexage interne des liaisons (utilisation d'éléments de type "3 états") (Fig.I-1-2-c). On
doit veiller à ce qu'en aucun cas 2 éléments configurés en émetteur commandent l'état du bus
simultanément.
Dans le cas général, plusieurs sous-ensembles peuvent être connectés sur un même
bus, ce qui permet de minimiser le nombre d'interconnexions.
Symbole
E R E 4 R
a) Bus uni-directionnel
Symbole
b) Bus bi-directionnel
commande
3 états
Figure I-1-2
-6-
BUS BUS
EXTERIEUR
E/S UT MEM
Figure I-1-3
-7-
I-1 FONCTION MEMOIRE
I-1-1 Définitions
Une mémoire est un ensemble de cellules élémentaires qui stockent chacune un bit. Le
nombre de cellules est appelé "capacité" de la mémoire. A chaque cellule sont associées 2
informations (Fig. I-1-4) :
Cellules
Adresse : Données :
numéro de Contenu
la cellule de la cellule
Figure I-1-4
Note : la plupart des mémoires à semi-conducteur sont à accès aléatoire. Par contre les
mémoires dites "de masse" qui ne sont pas décrites ici (disques, bandes, mémoires à bulles,..)
sont à accès séquentiel.
* Fonctionnement en lecture
Chaque cellule peut être lue indépendamment si l'on connecte sa sortie à une entrée
d'un multiplexeur (n --> 1).
Les entrées de sélection du multiplexeur reçoivent l'adresse.
-8-
La réalisation la plus simple pour la cellule est une simple connexion à 1 ou à 0 selon
l'état à lui donner (solution câblée).
Dans ce cas, la mémoire est dite à lecture seule.
E CK
D Q
CK
D D Q
CK E M
R/W S
M U
D Q
U X
CK
X
D Q
Cellule de base
2 CK
ADR. D Q
Figure I-1-5
* Fonctionnement en écriture
* Association en série
-9-
E
E1 E2
M M
E E
ADR N M M
1 2
D
R/W E
M
U
X
S1 S2
MUX
AN+1
S
Figure I-1-6
Cette organisation est obtenue en mettant en parallèle des mémoires de 1 bit (Fig.I-1-
7).
ENTREE
N
ADR
R/W
SORTIE
Figure I-1-7
-10-
N/2
DECODEUR
ADRESSE D
E
C
O
N/2 D
colonne E
U
R
sélect.
ligne
MUX./DEMUX
donnée
DONNEE
Figure I-1-8
Les mémoires mortes sont caractérisées par le fait qu'elles sont à lecture seulement.
L'état de chaque cellule est déterminé par son forçage à 1 ou à 0 réalisé par exemple par la
présence ou l'absence d'une connexion.
-11-
D
E
C
O
D
E
U
R
2 --> 4
ADRESSES
MULTIPLEXEUR 4-->1
SORTIE
Figure I-1-9
Le principe des PROM est similaire, mais la connexion est réalisée par un fusible
(Fig.I-1-10-a). Toutes les cellules sont initialement dans le même état (fusibles intacts). Dans
une phase de "programmation", les cellules devant avoir l'état opposé à l'état initial sont
sélectionnées successivement et un courant d'intensité élevée est appliqué afin de fondre le
fusible. Ces cellules ne pourront plus changer d'état par la suite.
Le principe des EPROM est analogue, mais la connexion est réalisée par un transistor
à effet de champ (Fig.I-1-10-b). La technologie utilisée est de type "MOS à grille flottante"
(Fig.I-1-11).
Cellule PROM à fusibles Cellule EPROM
Fus
(a) (b)
Figure I-1-10
-12-
AL AL
source drain
grille flottante
SiO2
P+ SUBSTRAT N P+
Figure I-1-11
A l'état initial la connexion est établie car le transistor est conducteur. Pour bloquer le
transistor, on applique une tension supérieure à la tension de claquage de la jonction PN ; des
électrons de forte énergie sont alors injectés dans la grille flottante. Une fois la tension
disparue, ces électrons restent prisonniers car la grille est entourée d'isolant.
Pour changer l'état des cellules, seule une exposition de la mémoire au rayons
ultraviolet permet d'extraire les électrons prisonniers dans la grille et ainsi de remettre la
mémoire dans son état initial pour une nouvelle programmation. Ici il s'agit d'un effacement
global de la mémoire.
Dans le cas des EEPROM, la cellule est plus complexe car elle doit permettre
l'évacuation des charges stockées dans la grille. Le retour à l'état initial (effacement) est
réalisé par l'application d'une tension de "déprogrammation". L'effacement est sélectif.
Notes : - une variante de ces mémoires est connue sous le nom de mémoire "FLASH".
- dans les mémoires programmables, les temps d'écriture ou d'effacement sont
beaucoup plus grands que les temps d'accès à l'information en lecture.
Les mémoires vives également appelées RAM permettent un accès aléatoire à chaque
cellule aussi bien en lecture qu'en écriture. On distingue ici deux types fonctionnant selon des
principes différents :
- les mémoires statiques (SRAM),
- les mémoires dynamiques (DRAM).
* Mémoires statiques
Ici chaque cellule est constituée par un élément bistable (Flip-Flop) (Fig.I-1-12-a).
Une fois mise dans un certain état par l'opération d'écriture, la cellule reste dans cet état
jusqu'à une écriture de l'état opposé ou jusqu'à disparition de la tension d'alimentation.
- s'il est actif, la mémoire fonctionne selon le mode déterminé par la ligne d'écriture-lecture,
-13-
- s'il est inactif, l'écriture est impossible, et en lecture, le bus de donnée est mis en haute
impédance.
LIGNES DE DONNEES Adresse
VCC
Donnée
SRAM
R/W
Sélection(/CS)
VSS
LIGNE DE SELECTION
a) b)
Figure I-1-12
Une grandeur importante est le temps d'accès de la mémoire caractérisé par le temps
qui s'écoule entre l'application d'une adresse et la disponibilité en sortie d'une donnée valide.
Ce temps détermine la fréquence maximum d'utilisation de la mémoire.
La période minimum est appelée temps de cycle. Les chronogrammes typiques d'une
SRAM sont présentés (Fig.I-1-13).
T cycle (lecture) T cycle (écriture)
ADRESSE ADRESSE
T AS TCS
Figure I-1-13
* Mémoires dynamiques
Les mémoires dynamiques fonctionnent selon un principe différent. Chaque cellule est
constituée d'un condensateur dont la charge représente l'état (Fig.I-1-14-a). Une fois chargé,
le condensateur ne peut se décharger que dans une résistance très élevée (technologie MOS).
La constante de temps de décharge de l'ordre de quelques mS impose de "rafraîchir"
chaque cellule par un accès périodique en écriture ou en lecture.
-14-
Sélection de ligne Adresse
Entrée
Ligne de bit
Sortie
DRAM
R/W
Condensateur /RAS
de stockage
/CAS
a) b)
Figure I-1-14
La disposition interne des cellules est toujours matricielle. Du fait du nombre élevé de
lignes d'adresse nécessaire à l'adressage d'un grand nombre de cellules, il devient nécessaire
de multiplexer les adresses lignes et colonnes pour diminuer le nombre de connexions du
boîtier mémoire.
D'autre part, la seule activation de /RAS rafraîchit simultanément toutes les cellules
d'une ligne dont le numéro est fourni sur le bus d'adresse.
- mode "page" permettant un accès rapide aux éléments d'une même ligne,
- rafraîchissement par séquence "/CAS avant /RAS" utilisant un compteur interne,
- lecture-modification-écriture,
- etc...
-15-
T cycle T cycle
CAS CAS
T su Th
T rac
DONNEE
valide DONNEE valide
T cac
T su Th T su Th
LECTURE ECRITURE
Figure I-1-15
On notera que dans les mémoires dynamiques le temps de cycle est différent du temps
d'accès à cause du temps de "préchargement (Tcrp)". Seul le temps de cycle fixe la fréquence
maximum de fonctionnement de la mémoire.
Lorsqu'il y a plusieurs lignes de sélection, la mémoire est activée quand toutes les
lignes sont actives simultanément (opérateur ET logique interne).
Une mémoire non sélectionnée a son bus de données à l'état haute impédance en
lecture et n'est pas modifiée par une opération d'écriture. Ceci permet d'associer en série
plusieurs boîtiers en reliant ensemble les bus d'adresse, de donnée et de lecture-écriture. Les
lignes d'adresse supplémentaires sont décodées par un démultiplexeur qui commande les
lignes de sélection des boîtiers (Fig.I-1-16).
-16-
ADR. N
ADR. SUP
DONNEE
D
SELECT. E
M Sélections
U
X
Figure I-1-16
ADR. N ADR. N
D DONNEE D DONNEE
/CAS. E /RAS. E
M M
U U
X X
Figure I-1-17
Cette RAM garde son contenu même après coupure de l'alimentation du système dans
lequel elle est installée. On trouve 2 concepts :
- maintien de la tension d'alimentation par une pile ou une batterie associée en "tampon"
avec l'alimentation de la mémoire. La technologie est de type CMOS pour obtenir une
consommation très réduite (quelques micro-ampères) durant la phase de maintien.
- association d'une EEPROM et d'une RAM dans un même boîtier. Ce concept permet de
cumuler les avantages des 2 technologies. L'utilisateur travaille avec une RAM dont le
contenu est sauvegardé dans l'EEPROM au moment de la coupure et restitué à la mise sous
tension.
On en distingue 2 sortes :
-17-
Il s'agit essentiellement d'une SRAM possédant 2 bus d'accès indépendants (adresse,
donnée, commande) et des lignes supplémentaires indiquant les conflits d'accès en écriture à
la même cellule. Ce type de mémoire est utilisé pour le partage et l'échange de données entre
2 systèmes.
Il s'agit d'une DRAM à laquelle est associé un registre à décalage dont la longueur
est égale à celle d'une ligne de la matrice mémoire (Fig.I-1-18). En plus des cycles classiques
propres aux DRAM, il existe des cycles spéciaux de transfert mémoire-registre et registre-
mémoire.
signaux
DRAM
256
partie
lignes
DRAM Transfert
VRAM
Transfert TRF
partie
E S
signaux VIDEO
REGISTRE
VIDEO H
Figure I-1-18
Les lignes d'adresse ne sont pas accessibles à l'extérieur : le type d'accès est ici
séquentiel ou série.
En plus des lignes de donnée, d'écriture et de lecture, on trouve les lignes d'indication
de "registre vide" et "registre plein". La première signale l'égalité des pointeurs, la seconde
que le pointeur d'écriture "rattrape" celui de lecture. Ces lignes permettent de gérer
correctement le transfert d'informations entre 2 systèmes qui peuvent travailler à des
fréquences différentes (asynchronisme).
Il existe également des lignes permettant de "cascader" plusieurs FIFO pour obtenir
de plus grandes capacités.
-18-
MEMOIRE Pointeur
DONNEES DONNEES
lecture
Pointeur
écriture
FIFO
ECRITURE LECTURE
"PLEIN" "VIDE"
Figure I-1-19
-19-
I-2 L'UNITE DE TRAITEMENT
La première fonction est réalisée par une Unité Arithmétique et Logique (ALU).
Chaque instruction est codée sous forme binaire ; l'unité de traitement doit donc en
assurer le décodage pour déduire les opérations élémentaires à effectuer. Pour cela elle
dispose d'un registre d'instruction qui présente à une unité de commande (U.C.) ou
"séquenceur", le mot codant l'instruction courante.
Sous l'action d'une horloge, l'U.C. élabore les commandes nécessaires à l'exécution de
l'instruction. Dans le cas général, elle tient également compte du contenu du registre d'état
où sont enregistrés certains résultats liés au déroulement des instructions (dépassements,
résultats nuls,...).
Les données et les adresses sont véhiculées par des bus en général de formats
différents :
-20-
- le bus d'adresse détermine la capacité maximale d'adressage du système, c'est à dire le
nombre maximum de mots de la mémoire associée (ex : 16 bits "adressent" 64 Kmots).
Dans certains cas, ces 2 bus sont multiplexés sur un seul bus. Une logique externe doit
alors effectuer le démultiplexage.
Un certain nombre de signaux pour la gestion des échanges avec la mémoire et les
organes d'entrée-sortie sont rassemblés dans un "bus de commande".
L'architecture interne d'une unité de traitement peut être schématisée par la figure I-2-
1.
UNITE DE TRAITEMENT
MICROCOMMANDES
HORLOGE
U.C.
BUS DE COMMANDE
INSTRUCTION ETAT PC
BUS DE DONNEE
REGISTRE(S) REGISTRE(S)
BUS D'ADRESSE
DE
ALU
DONNEE D'ADRESSE
BUS INTERNE
Figure I-2-1
Comme son nom l'indique, cette unité peut exécuter 2 types d'opérations.
- Opérations arithmétiques
Elles incluent l'addition et la soustraction qui sont des opérations de base (une
soustraction est une addition avec le complément à deux), la multiplication et la division.
Les données traitées sont considérées dans des représentations "entières".
Les opérations plus complexes (sinus, log, exp,..) peuvent être obtenues à partir des 4
opérations (par exemple par développement limité). Elles sont réalisées dans une unité de
calcul spécialisée (FPU : Floating Point Unit) qui traite des données en représentation en
"virgule flottante".
- Opérations logiques
-21-
Ces opérations sont effectuées bit à bit sur les bits de même poids de 2 mots (Fig.I-2-
2). On trouve : ET, OU, OU exclusif, PAS,...
N-1 0
A
N-1 0
B OPERATIONS : ET,OU,XOR
N-1 0
C
Figure I-2-2
Un autre type d'opérations concerne les décalages et rotations (droite et gauche). Ces
différentes opérations diffèrent par la façon d'entrer et de sortir les bits de poids extrêmes
(Fig.I-2-3). Elles sont utilisées par exemple pour effectuer la multiplication et la division à
partir de l'addition et la soustraction.
N-1 0 N-1 0
C 0 0 C
Décalages logiques
N-1 0 N-1 0
C 0 C
Décalages arithmétiques
N-1 0 N-1 0
C C
Rotations
Figure I-2-3
Après chaque opération effectuée dans l'ALU, le registre d'état contient un certain
nombre d'informations liées à leur exécution. On trouve généralement : signe du résultat,
résultat nul, dépassement de capacité (retenue ou Carry (C)), etc..
-22-
Ces registres servent à gérer l'adressage de la mémoire. Parmi ceux-ci, un registre est
fondamental dans l'exécution du programme : le compteur ordinal (Program Counter). Il
contient l'adresse de l'instruction courante.
Ces registres sont plus spécialement adaptés au traitement des éléments d'un tableau.
Ils sont en général munis de propriétés d'incrémentation et de décrémentation.
Un cas particulier de pointeur est le pointeur de pile (Stack Pointer SP). Ce registre
permet de stocker des données ou des adresses selon le principe du "Dernier Entré Premier
Sorti" ou "LIFO" (Last In First Out). Dans certain cas, la pile est contenue dans l'U.T., mais la
plupart du temps elle est située en mémoire. Nous analyserons son mécanisme ultérieurement.
- de façon câblée, par les éléments classiques de la logique séquentielle (portes, bascules, ..),
-23-
I-2-2 Aspect logiciel
Les instructions peuvent porter soit sur les données, soit sur les adresses.
Dans le premier cas, il s'agit d'un traitement essentiellement effectué dans l'ALU, par
exemple : addition, décalage, opérations logiques, transfert U.T. <--> mémoire, etc...
Dans la plupart des cas, l'instruction présente en mémoire contient ces 2 informations
dans des mots consécutifs.
Le nombre d'instructions (jeu d'instructions) est directement lié au format du code-
opération. Ainsi un octet permet de distinguer au maximum 256 instructions différentes.
* Adressage implicite
Ici les opérandes sont désignés dans le code-opération ; les données concernées se
trouvent dans les registres internes de l'U.T. (Fig.I-2-4).
***********
-24-
Format : * CODE-OP *
***********
MEMOIRE
PC CODE OP
UT
opération
interne
IMPLICITE
Figure I-2-4
* Adressage immédiat
************* ************
Format : * CODE-OP * * VALEUR *
************* ************
MEMOIRE
PC CODE OP
UT opérande
IMMEDIAT
Figure I-2-5
************ ************
Format : * CODE-OP * * ADRESSE *
************ ************
-25-
MEMOIRE
PC CODE OP
UT ADR.
ADR opérande
ETENDU
Figure I-2-6
* Adressage indirect
- par registre : l'opérande est trouvé à l'adresse pointée par le registre, celui-ci étant
désigné dans le code-opération (mode implicite),
- par la mémoire : l'opérande est trouvé à l'adresse contenue dans la case mémoire
dont l'adresse est indiquée à la suite du code-opération.
************ **************************
Format : * CODE-OP * * ADRESSE DE L'ADRESSE *
************ **************************
MEMOIRE MEMOIRE
PC CODE OP PC CODE OP
UT UT ADR1
ADR1 ADR2
REGISTRE opérande
ADR2 opérande
INDIRECT(registre) INDIRECT(mémoire)
Figure I-2-7
-26-
************ *****************
Format : * CODE-OP * * DEPLACEMENT *
************ *****************
MEMOIRE
PC CODE OP
UT DEPL.
INDEX
DEPL.
opérande
INDEXE
Figure I-2-8
* Adressage auto-indexé
Le calcul de l'adresse est identique au cas précédent, mais le registre concerné est
modifié. Plusieurs cas sont possibles :
MEMOIRE MEMOIRE
PC CODE OP PC CODE OP
UT UT
(1) (2)
SP SP (1)
SP SP (2)
SP SP
Figure I-2-9
Note : l'ordre de ces opérations peut être inversé dans certaines machines.
-27-
I-2-2-4 Instructions de saut
- le saut inconditionnel,
- le saut conditionnel.
Dans le premier cas, le PC est chargé avec l'adresse spécifiée dans l'instruction
(plusieurs modes d'adressage sont possibles). La prochaine instruction sera exécutée à partir
de cette adresse.
MEMOIRE MEMOIRE
PC CODE OP PC CODE OP
UT ADR UT ADR condition
(CODE OP) PC
non réalisée
ADR (CODE OP) PC ETAT
condition
ADR (CODE OP) PC
réalisée
avant après avant après
SAUT INCONDITIONNEL (étendu) SAUT CONDITIONNEL
Figure I-2-10
* Sous-programme
Lorsqu'un même programme est utilisé plusieurs fois, il serait maladroit de réécrire ce
programme à chaque fois qu'on en a besoin. Il faut donc que ce programme soit "appelable"
de plusieurs endroits en mémoire et qu'après son exécution, le déroulement reprenne à
l'instruction suivant celle d'appel.
-28-
Si l'on désire que, pendant l'exécution du sous-programme on puisse appeler un autre
sous-programme et ainsi de suite, il est nécessaire de pouvoir stocker autant d'adresses de
retour qu'il y a de sous-programmes appelés (niveaux de sous-programmes).
La gestion du stockage de ces adresses ne peut se faire que par le mécanisme de pile
(Dernier Entré - Premier Sorti). La taille de la pile fixe le nombre maximum de niveaux
admissibles (Fig.I-2-11).
RETOUR RTS
PILE
APPEL DE SOUS-PROGRAMME
Figure I-2-11
ADR2 (3)
PILE PILE PILE PILE PILE
(5) (4) (2) (3) (4) (5)
(1)
IMBRICATION DE SOUS-PROGRAMMES
Figure I-2-12
-29-
I-3 LES ORGANES D'ENTREE-SORTIE
I-3-1-1 Isolation-Mémorisation
Ces 2 fonctions sont réalisables par des registres aussi bien en entrée qu'en sortie ; on
parle de "portes d'entrée-sortie" (Input-Output Port).
En sortie, ces fonctions sont réalisées par un registre de type "D" (Fig.I-3-1-a).
En entrée, généralement seule la fonction isolation est réalisée par un élément "tampon
3 états" (Fig.I-3-1-b). C'est alors au périphérique de maintenir la donnée stable sur le bus
externe pendant la durée de sa prise en compte.
E/S E/S
CK /CS
ECRITURE LECTURE
a) b)
Figure I-3-1
I-3-1-2 Synchronisation
-30-
Des lignes de dialogue doivent indiquer qu'une donnée est disponible en entrée ou en
sortie. Ces lignes peuvent être considérées comme des entrées "normales" de données ou bien
comme des lignes spécialisées.
CK évènement externe
VERS BUS DONNEE
1
Q D
CLEAR
LECTURE
RAZ
Figure I-3-2
En général, les états des différentes bascules de synchronisation sont regroupés dans
un registre d'état.
Validation Validation
DONNEES DONNEES
E/S PERIPH. E/S PERIPH.
Acquittement Acquittement
Figure I-3-3
-31-
Les organes d'E/S et la mémoire sont adressés par le même bus d'adresse, mais
validés en écriture ou en lecture par des signaux distincts.
L'espace d'adressage des E/S est plus petit que l'espace mémoire, ce qui n'est pas
gênant, étant donné le nombre restreint de liaisons externes nécessaires à un système.
Pour activer ces E/S, des instructions spéciales sont nécessaires (IN, OUT).
Les organes d'E/S sont considérés comme des positions mémoire où l'on lit (Entrée)
ou écrit (Sortie) des données.
L'avantage de cette approche est que l'on peut utiliser le jeu d'instructions complet de
l’U.T. pour manipuler les informations provenant de ces organes.
L'inconvénient est que la zone d'E/S de petite dimension "empiète" sur l'espace total
adressable normalement réservé à la mémoire.
écriture
lecture MEM zone lect/ecr MEM MEM
mémoire zone
E/S mémoire
U.T. U.T. adressable
écriture MEM
lecture E/S zone E/S
E/S
a) b)
Figure I-3-4
Les organes d'E/S sont également chargés de transformer les informations parallèles
véhiculées sur le bus de donnée, sous une forme compatible avec celles des unités
périphériques utilisées.
-32-
Il existe 2 modes de transfert :
Le programme de transfert est donc une boucle dont la structure est présentée (Fig.I-3-
5).
(1)
UT E/S
prêt ?
N
O
(3) (2)
(2) et (3) Transfert donnée
Figure I-3-5
Remarque : dans ce programme, l'U.T. teste l'état du périphérique jusqu'à ce que ce dernier
soit prêt ; elle se synchronise sur la vitesse de celui-ci.
Un mode dans lequel le périphérique informe l'U.T. qu'il est disponible semble
préférable. Mais, dans ce cas, il faut pouvoir interrompre le fonctionnement de l'U.T.,
exécuter le programme de transfert avec l'E/S, puis reprendre le programme qui était
exécuté avant l'interruption sans avoir perdu d'informations.
- Définitions
Si le déroulement d'un programme peut être suspendu, puis repris, ce programme est
interruptible.
-33-
Si l'U.T. peut, par une instruction, inhiber ou autoriser la prise en compte
d'interruptions, les interruptions sont masquables.
L'état de l'U.T. est également appelé "contexte". Dans certains cas, seuls les contenus
du PC et du registre d'état sont sauvegardés. La sauvegarde des registres utilisés dans le
programme d'interruption doit être prise en charge dans ce programme.
- elle peut être contenue dans un "vecteur d'interruption" situé dans une adresse fixe
en mémoire : le branchement à ce programme s'effectue donc par un saut indirect,
- elle peut être fournie par l'organe d'E/S au moment de la prise en compte de
l'interruption.
Sauvegarde
UT E/S
(2)
(1)
(3)
(3) (2) Interruption
RTI
Restitution
Figure I-3-6
-34-
Note : le programme d'interruption est assimilable à un sous-programme, le moment et donc
le lieu de l'appel n'étant pas prévisibles.
- chaque E/S est connectée à une ligne d'interruption différente (Fig.I-3-7-a). L'U.T.
identifie directement l'organe demandeur ; un vecteur est affecté à chaque ligne. Lorsque
plusieurs demandes ont lieu simultanément, une règle de priorité est établie de façon
interne.
- toutes les E/S sont connectées à une entrée d'interruption commune (Ou câblé).
- solution matérielle.
- les organes d'E/S sont connectés entre-eux (chaînage ou "daisy chain"). En cas de
simultanéité d'interruption, la disposition des éléments dans la chaîne établit la priorité (Fig.I-
3-7-d).
-35-
IT1 IT
U.T. E/S U.T. E/S
IT2
VECT1
VECT2 (a) VECT (b)
acq
U.T. IT U.T. IT
E/S E/S
CONTROL.D'IT
MEM MEM
E/S E/S
VECT1 VECT1
VECT2 VECT2
(c) (d)
Figure I-3-7
Lorsque un programme d'interruption a été effectué, l'U.T. doit prendre en compte les
interruptions de niveau inférieur qui étaient présentes ou qui ont eu lieu depuis le traitement
de la première interruption.
De façon générale, les organes d'E/S peuvent être programmés pour activer les lignes
d'interruption au moment de l'apparition d’événements particuliers :
-36-
* Autres types d'interruption
On trouve :
Adresse de début
EXTERIEUR
Bloc E/S
Adresse de fin
Figure I-3-8
Pour cela, un circuit appelé contrôleur de DMA, prend en charge les différentes
opérations.
Dans le deuxième cas, le transfert s'effectue en 2 étapes (cas d'un transfert en entrée) :
- transfert de l'organe d'E/S vers le contrôleur,
- transfert du contrôleur vers la mémoire.
-37-
Ici le contrôleur contient les 2 adresses concernées. Dans ce cas, des transferts peuvent
être effectués de mémoire à mémoire (Fig.I-3-9-b).
BUS ADRESSE
BUS DONNEE
BUS ADRESSE BUS ADRESSE
(a)
Figure I-3-9
Une procédure d'échange possible dans le premier mode est la suivante (entrée de
données) (Fig.I-3-10) :
- le circuit d'E/S informe le contrôleur de DMA qu'il a reçu une donnée (1),
- le contrôleur demande à l'U.T. une mise à l'état haute impédance de ses bus (bus
request) (2),
- dès que l'U.T. a libéré les bus, elle avertit le contrôleur (bus grant) (3),
- le contrôleur effectue alors les opérations suivantes (4):
- positionnement de l'adresse mémoire,
- lecture de la donnée de l'organe d'E/S,
- écriture de cette donnée en mémoire.
BUS ADRESSE
R/W
(2) (1)
(3) (4)
IRQ
BUS DONNEE
Figure I-3-10
-38-
Le contrôleur dispose de registres internes programmables indiquant l'adresse de
début de bloc et le nombre de transferts à effectuer.
Les transferts sont réalisés à des adresses successives par incrémentation du registre
d'adresse et s'arrêtent lorsque le nombre programmé est atteint. A ce moment, l'U.T. est
avertie de cet événement, soit par lecture du mot d'état du contrôleur, soit par une interruption
issue de celui-ci.
Note : le contrôleur de DMA peut gérer des transferts de donnée avec plusieurs organes d'E/S.
Pour cela, il dispose de plusieurs "canaux" (lignes de dialogue et registres). Des règles de
priorité doivent être utilisées pour régler les conflits de demande de transfert (priorités fixe ou
tournante).
* Modes de DMA
Pendant tout le transfert, l'U.T. est arrêtée et ses bus sont en haute impédance.
Notons que le temps d'attente pour la prise en compte des bus peut être assez long, car l'U.T.
doit terminer l' instruction en cours avant de libérer les bus qu'elle commande.
Pour éviter l'arrêt complet de l'U.T., on peut lui dérober des cycles en agissant sur la
forme de l'horloge associée. Durant ces cycles, on effectue des transferts DMA. Une
conséquence est le ralentissement de l'exécution du programme.
Note : pour certaines U.T. de structure dynamique, il existe un intervalle de temps maximum
entre 2 tops horloge, ce qui limite le nombre de cycles consécutifs que l'on peut dérober et
donc la vitesse de transfert DMA.
Notons que le programme n'est pas ralenti par le transfert DMA mais que le temps
d'accès des mémoires utilisées doit être réduit par rapport à une utilisation normale.
-39-
1 cycle
Horloge
Demande DMA
a) Acquittement
1 cycle
Horloge
b) Cycles volés
Horloge U.T.
1 cycle
Horloge
c)
DMA U.T. DMA U.T. DMA U.T. DMA U.T. DMA U.T. DMA U.T.
Figure I-3-11
-40-
CHAPITRE II
Figure II-1-1
-41-
Le 8051 est relié à son environnement par 40 broches dont le rôle est explicité ci-
dessous (E : entrée, S : sortie, E/S entrée-sortie) :
Les broches de certains ports ont un rôle particulier dans le fonctionnement du 8051 :
- le port 0 est utilisé comme bus d’adresse de poids faible A7-A0 multiplexé avec le
bus de données D7-D0,
- le port 2 est utilisé comme bus d’adresse de poids fort A15-A8,
- le port 1 peut véhiculer les signaux suivants :
- T2 entrée Timer 2 (80C154),
- T2EX entrée flag Timer 2 (80C154),
- le port 3 véhicule les signaux suivants :
- RXD entrée série,
- TXD sortie série,
- /INT0 entrée d’interruption 0,
- /INT1 entrée d’interruption 1,
- T0 entrée Timer 0,
- T1 entrée Timer 1,
- /WR signal d’écriture,
- /RD signal de lecture.
-42-
Figure II-1-2
Figure II-1-3
-43-
Figure II-1-4
-44-
II-1-2 Organisation interne
Le modèle simplifié du 8051 est présenté à la figure II-1-5.
7 0
PILE SP
4 bancs de 8 registres 8 bits
B
R0
R1 ACCU A
R2 ETAT PSW
R3
R4 15 8 7 0
R5 PC PCH PCL
R6 INDEX DPH DPL
R7
Figure II-1-5
Le 8051 possède une RAM interne de 128 octets (ou 256 selon le modèle) et un
ensemble de registres appelés SFR (Special Function Register). Parmi ces registres, on
distingue :
- 4 registres de 8 bits : 1 accumulateur (A ou ACC), 1 registre (B), 1 registre d'état
(PSW), 1 pointeur de pile (SP),
- 2 registre de 16 bits : 1 compteur ordinal (PC), 1 pointeur de données (DPTR).
Bit n° 7 6 5 4 3 2 1 0
CY AC F0 RS1 RS0 OV F1 P
La RAM interne possède des emplacements pouvant être utilisés comme registres.
Ainsi la zone (00-1F) peut contenir 4 bancs de 8 registres (R7-R0). Chaque banc est
sélectionnée par les bits RS1 et RS0 de PSW selon la table de vérité suivante :
-45-
RS1 RS0 Sélection
0 0 Banc 0 (00-07)
0 1 Banc 1 (08-0F)
1 0 Banc 2 (10-17)
1 1 Banc 3 (18-1F)
Figure II-1-6
-46-
La figure II-1-7 détaille le rôle des bits de IE et la figure II-1-8 celui de IP.
Figure II-1-7
Figure II-1-8
Figure II-1-9
-47-
Le tableau suivant donne l’état des différents registres après un RESET.
PC 0000H
A 00H
B 00H
PSW 00H
SP 07H
DPTR 0000H
P0-P3 FFFFH
IP XXX00000B
IE 0XX00000B
TMOD 00H
TCON 00H
TH0 00H
TL0 00H
TH1 00H
TL1 00H
SCON 00H
SBUF XXH
PCON 0XXXXXXXB
Exemple :
-48-
Opération Mnémonique Instruction en hexadécimal
A + 1 -> A INC A 04
Exemple :
Exemple :
Exemples :
- par registre
- par adresse
((adresse))->A MOV A,@adresse 8 bits (RAM interne)
Exemple :
-49-
Saut conditionnel si A=0 (JZ : Jump If Zero) (code opération : 60)
PC JZ
PC+1 OFFSET K
PC+2 XX (instruction suivante)
........................
.
--> PC+2+K INSTRUCTION DU SAUT
Exemples :
PC 60 PC-3 <--------
PC+1 03 PC-2 |
PC+2 | PC-1 |
PC+3 | PC 60
PC+4 | PC+1 FB (-5)
PC+5 <------- PC+2
Si la condition est réalisée, le saut est effectué, sinon l'instruction suivante (PC+2) est
exécutée.
SP -> 0007 xx
sens de | 0008 A1
chargement | 0009 A2
de la pile v 000A xx
Pour le dépilement, la donnée concernée pointée par SP est restituée, puis le SP est
décrémenté de 1.
-50-
b) Appel de sous-programme
Lors d'un appel de sous-programme, on se déroute du programme principal pour
exécuter ce sous-programme. Il est alors nécessaire de mémoriser l'adresse de l'instruction (du
programme principal) qui suit immédiatement l'appel du sous-programme, pour que le PC
vienne se recharger avec cette adresse lors du retour du sous-programme.
- programme : 1000 12
1001 00
1002 29
1003 xx (instruction suivante)
- programme : 120A 22
c) Interruptions
Les procédures d'interruption sont similaires aux sous-programmes, mais l'instant et
donc le lieu de déroutement du programme principal ne sont pas connus. Dans ce cas,
l'adresse de retour est automatiquement sauvegardée dans la pile. On exécute alors un
programme d'interruption à la fin duquel l'instruction RETI place l'adresse de retour dans le
PC, ce qui permet de reprendre le programme à l'endroit où avait eu lieu l'interruption.
-51-
- TM1 : Interruption Timer 1
- SI0 : Interruption Série
- TM2 : Interruption Timer 2 (80C154)
Lorsqu'une interruption externe est demandée et si elle n’est pas masquée, le 8051
termine l'opération en cours et ayant identifié la source d’interruption, saute à l’adresse
associée. Il trouve à cette adresse, soit le programme d'interruption correspondant, soit une
instruction de saut à ce dernier.
La table des interruptions est indiquée ci-après :
RST 0000H
INT0 0003H
TM0 000BH
INT1 0013H
TM1 001BH
SI0 0023H
TM2 002BH
ATTENTION : le programme d'interruption doit sauvegarder les registres utilisés autres que
PC.
Dans le cas où plusieurs interruptions de type différent se produisent, les registres IE
et IP définissent les autorisations et règles de priorité, le registre TCON les conditions de
déclenchement (niveau ou front).
-52-
II-2 L'INTERFACE PARALLELE 8255 (Programmable Peripheral
Interface PPI)
/CS PA7-PA0
groupe A
A0 PC7-PC4
A1
/RD PC3-PC0
/WR groupe B
RESET PB7-PB0
D7-D0
Figure II-2-1
Les lignes connectées sur l'extérieur sont au nombre de 24 : 3 bus (ports) de 8 bits
(PA0-PA7, PB0-PB7, PC0-PC7). Les 3 ports sont associés selon 2 groupes : le groupe A
associe le port A et le quartet fort de C ; le groupe B associe le port B et le quartet faible de
C.
L’adressage des différents ports se fait selon les tables de vérité suivantes :
-53-
II-2-1 Modes de fonctionnement
Les modes de fonctionnement sont déterminés par l'état d’un registre contenant le mot
de contrôle : "Control Word" (CW).
On distingue 3 modes qui déterminent la façon dont sont utilisés les ports d’E/S :
- le mode 0 appelé : Basic Input/output,
- le mode 1 appelé : Strobed Input/output,
- le mode 2 appelé : Bi-Directional Bus.
Dans le mode 0, les ports peuvent être programmés en entrée ou en sortie (8 bits pour
Aet B, 2*4 bits pour C). Les sorties sont mémorisées dans des bascules D. Les entrées ne sont
pas mémorisées. Il y a 16 configurations possibles. Aucune ligne de dialogue n’est disponible.
Dans les modes 1 et 2, les ports A et B peuvent être programmés en entrée ou en
sortie, le port C regroupant des lignes de dialogue et des lignes d’E/S. Certaines lignes de
dialogue peuvent être utilisées comme demande d’interruption.
Ceci est résumé sur la figure II-2-2.
Figure II-2-2
-54-
Le mot de contrôle permet de déterminer le mode choisi ainsi que le sens de transfert
des données avec le monde extérieur.
Le bit 7 du CW établit le mode d’accès aux différents ports. Lorsqu’il est à 1, il s’agit
d’un accès normal par octets (Fig. II-2-3), lorsqu’il est à 0, il s’agit d’un accès au niveau du
bit (Fig. II-2-4). Dans ce dernier cas, chaque bit du port C peut être mis sélectivement à 0 ou à
1.
Figure II-2-3
-55-
Figure II-2-4
-56-
II-3 LES TRANSMISSIONS SERIE
II-3-1 Généralités
II-3-1-1 Communications asynchrones
II-3-1-2 Communications synchrones
II-3-2 Exemple d'interface série : l'ACIA MC 6850
II-3-2-1 Présentation du circuit
II-3-2-2 Fonctionnement
II-3-1 Généralités
parité
START 0 1 N-1 STOP
(option.) (1 ou 2 bits)
Figure II-3-1
La cadence de transmission est fixée par une horloge dont la période donne le temps
de transmission de 1 bit. La cadence de transmission exprimée en bit/s ou bauds est l'inverse
de cette période.
Au repos, la ligne de transmission est à l'état 1 (Mark). Le début de transmission est
signalé par l'apparition du bit de départ qui est dans l'état logique 0 (Space).
Un bit de parité est ajouté éventuellement à la suite des bits de donnée. Il permet de
détecter des erreurs de transmission.
La fin de transmission du caractère est signalée par un ou plusieurs bits d'arrêt à l'état
1.
-57-
de chacun des bits). Ainsi, comme les fréquences d'émission et de réception ne sont pas
strictement identiques, il suffit de garantir une précision de quelques pour-cent pour assurer
une réception valide.
Les vitesses normalisées sont : 50, 75, 110, 150, 300, 600, 1200, 2400, 4800, 9600,
19200, 38400 bauds.
Ici les données forment un flot continu de bits. Il est donc nécessaire d'effectuer la
synchronisation des caractères au début du bloc de données. Cette synchronisation peut être
interne ou externe.
La synchronisation externe nécessite une ligne spécialisée qui fournit un top à chaque
début de transmission de bloc.
Dans tous les cas, une horloge cadence la transmission des bits qui ne sont donc émis
qu'à des instants déterminés.
A la réception, on dispose soit de l'horloge et des données séparées, soit des données
seules. Dans ce dernier cas, le récepteur doit reconstituer l'horloge à partir des données (par
exemple avec une boucle à verrouillage de phase).
- Byte Control Oriented Protocol (BCP), où chaque champ a une signification octet par octet,
- Bit Oriented Protocol (BOP), où chaque bit d'un champ peut avoir une signification
particulière.
La première est de moins en moins utilisée. La seconde est utilisée dans la procédure
HDLC (High Level Data Link Control).
-58-
L'information est véhiculée dans des trames séparées par des caractères de
synchronisation.
- Délimitation
- Contenu de la trame
a) champ adresse 8/16 bits désigne le numéro de la station concernée (dans un réseau),
b) champ de commande 8/16 bits caractérise le type de trames,
c) champ d'information comprenant un nombre quelconque de bits,
d) champ de contrôle d'erreur FCS (Frame Control Sequence) sur 16 bits.
- transparence
-59-
TXCK
/IRQ TX
D0-D7 /RTS
RS /CTS
CS0 /DCD
CS1
/CS2
R/W
E RX
RXCK
D A C
Figure II-3-2
-60-
CS0*CS1*/CS2 RS R/W FONCTIONS
1 0 0 Ecriture du REGISTRE DE COMMANDE RC
1 0 1 Lecture du REGISTRE D'ETAT RE
1 1 0 Ecriture du REGISTRE TRANSMISSION RT
1 1 1 Lecture du REGISTRE RECEPTION RR
0 X X Pas d'opération
Figure II-3-3
II-3-2-2 Fonctionnement
a) Transmission
Une donnée fournie par le bus donnée est d'abord introduite dans le registre RT, puis,
s'il n'est pas en train de transmettre, dans le registre RS, à partir duquel elle sera transmise en
série suivant le format dont les caractéristiques sont précisées dans le registre de commande
RC.
Lorsque RT est vide (quelque soit l'état du registre de sérialisation RS), l'ACIA
positionne le bit TDRE du registre d'état à 1 et l'ACIA émet une demande d'interruption si elle
est autorisée (/IRQ = 0) et positionne à 1 le bit IRQ du registre d'état.
b) Réception
-61-
- un registre de désérialisation (RD) transformant l'information série reçue, en information
parallèle "expurgée" des bits de START, STOP et PARITE, qui sera envoyée au registre de
réception RR, qui le délivrera (sur lecture) sur le bus de données.
Dès que ce registre de réception RR est "plein", le bit RDRF du registre d'état est mis
à 1 et l'ACIA émet une demande d'interruption /IRQ = 0 (si elle est autorisée) et positionne à
1 le bit IRQ du mot d'état.
c) Programmation et utilisation
- Mot de commande
D7 D6 D5 D4 D3 D2 D1 D0
RIE TC2 TC1 WS3 WS2 WS1 CDS2 CDS1
D1 D0 OBSERVATION
0 0 CK/1
0 1 CK/16
1 0 CK/64
1 1 RAZ
-62-
Format de l'information (Emission et Réception) :
D6 D5 FONCTION
0 0 /RTS=0 Interruption transmetteur inhibée
1 0 /RTS=0 Interruption transmetteur autorisée
1 0 /RTS=1 Interruption transmetteur inhibée
1 1 /RTS=0 Interruption transmetteur inhibée
Transmission du caractère BREAK
D7 SIGNIFICATION
0 Interruption du récepteur inhibée
1 Interruption du récepteur autorisée
- Mot d'état
D7 D6 D5 D4 D3 D2 D1 D0
IRQ PE OVRN FE /CTS /DCD TDRE RDRF
-63-
- OVRN : Over Run (surcharge). Quand un ou plusieurs caractères ont été reçus avant la
lecture du caractère précédent, ce bit est mis à 1.
- FE : Framing Error (erreur de format). Ce bit à 1 indique une erreur sur la donnée reçue :
. erreur de synchronisation,
. absence de bit de stop,
. réception d'un BREAK.
- /CTS : Clear To Send (inhibition de l'émetteur). Ce bit reflète l'état de l'entrée /CTS.
- /DCD : Data Carrier Detect (détection de porteuse). Ce bit reflète l'état de l'entrée /DCD.
- TDRE : Transmit Data Register Empty (registre de transmission vide). Ce bit est à 1 quand
RT est disponible (soit une transmission est en cours dans RS, soit elle est achevée). Il passe à
0 à la suite d'un chargement de RT.
- RDRF : Receive Data Register Full (registre de réception plein). Ce bit est à 1 quand le
registre de réception RR contient une donnée. Il passe à 0 à la suite de la lecture du registre
RR par le microprocesseur.
Remarque : une commande RAZ positionne à 0 les bits : RDRF, FE, OVRN, PE.
-64-
CHAPITRE III
III-1 DESCRIPTION DU MATERIEL DE TRAVAUX PRATIQUES
III-2 DESCRIPTION DE LA CARTE MICR0CONTROLEUR 8051
III-3 DESCRIPTION DE LA PLAQUETTE DE TP-CNA
III-4 TRAVAIL A REALISER
III-4-1 Utilisation de l’environnement MUVISION
III-4-2 Exercices de programmation
III-4-3 Sortie d’informations
III-4-4 Conversion analogique-numérique
III-4-5 Acquisition de données
GENE
BF
PPI-D PPI-U
PC PIA OSCILLO
TP-CNA
E
Carte 8051 Y
X
Figure III-1
-65-
III-2 DESCRIPTION DE LA CARTE MICR0CONTROLEUR 8051
La carte 8051 comprend les éléments suivants (fig. III-2) :
- un microcontrôleur 8051 fonctionnant à 12 MHZ,
- une PROM de 2Koctets (2716) ou 8Koctets (27C64),
- une RAM de 8Koctets,
- 2 circuits d’interface parallèle (PPI) de type 8255,
- une interface série RS232 (non utilisée ici).
Un ensemble logique non représenté assure les fonctions de décodage et de
démultiplexage d’adresse , d’initialisation,...
On trouvera le schéma détaillé de la carte en annexe.
8051
PROM
RS232 2k*8/ RAM PPI-D PPI-U
8k*8 8k*8
PC Utilisateur
Figure III-2
Soit :
-66-
III-3 DESCRIPTION DE LA PLAQUETTE DE TP-CNA
La plaquette de TP-CNA (fig.III-3) comprend un ensemble de circuits permettant
d’effectuer la conversion numérique-analogique sur 8 bits de 2 bus A et B provenant d’une
interface numérique.
+5V
13 1 2 1K
PA0 12
11 MC 1408
10 TL081 X
A 9 U1 4
8
7 1K
6 15 U3 +2V
PA7 1K
5 3 16 14
1K
47pF 1M
-12V +2V
1uF
+5V E (t)
13 1 2 1K
Interface numérique
PB0 12 SW1
11 MC 1408 Y T TL081
10 TL081 2N 4858
TL081 +
B 9 U2 4
8 U4 U6
+ Q1 U5
-
7 1K -
6 15
PB7 1K C1 1M
5 3 16 14 470 470 0,1uF
1K 10K
47pF TL081
+2V MC1710
-12V +
COMP - U7
U8 -
+ +5V
470K
+12V P1 +12V
+5V 47K
741 10K
3,3K 4,7K 100nF 4,7K 100nF
U10
+2V
1K
Q U9 A Q U9 A
2,2K
CL B CL B
74123
+5V +5V
BT
Figure III-3
-67-
A la voie Y est associé un ensemble comprenant un étage échantillonneur-bloqueur et
un comparateur, utilisé pour la conversion analogique-numérique programmée d'un signal
d'entrée E.
Le signal d'entrée E est appliqué à U5 par une liaison continue (DC) ou alternative
(AC) par l'intermédiaire de SW1. En mode (AC), une polarisation égale à Vref/2 est
appliquée à U5 afin de centrer la valeur moyenne du signal à convertir sur cette valeur.
L'échantillonnage est réalisé par le transistor à effet de champ Q1 et le blocage par le
condensateur C1. Le signal bloqué (T) est disponible à la sortie du suiveur U6. La commande
appliquée sur la grille de Q1 provient de U7 qui réalise une adaptation de niveau pour une
sortie TTL (niveau 1 --> Q1 bloqué, niveau 0 --> Q1 passant).
Le comparateur de type MC 1710 (U8) reçoit les signaux Y et T. Sa sortie (COMP) est
à 1 si Y < T.
Un oscillateur utilisant 2 monostables rebouclés de type SN 74123 (U9) fournit un
signal de base de temps (BT) dont la durée à l'état haut est constante (temps de blocage), et
celle à l'état bas variable par l'intermédiaire de P1. Le signal BT est envoyé à
l'échantillonneur-bloqueur.
Les 2 signaux COMP et BT sont envoyés vers l’interface numérique. Celle-ci peut être
réalisée soit par un PPI de type 8255 (cas où l’on connecte la plaquette de TP-CNA à la carte
8051), soit par 2 PIA 6821 (cas où l’on connecte la plaquette de TP-CNA directement à la
carte PIA du PC).
La figure III-4 montre les connexions réalisées suivant les 2 cas.
CA1 BT
PA
PB PIA4 PA
PB
INT1 PC7 BT
COMP PIA0 COMP
PC4 PA7
PPI PIA
Figure III-4
C’est la première configuration (PPI) qui est utilisée ici (PPI user d’adresse de
base 6000H). Il faut noter que le signal BT est envoyé simultanément sur l’entrée PC7 du
PPI et sur l’entrée d’interruption INT1 du 8051.
-68-
III-4 TRAVAIL A REALISER
ETAPES DE DEVELOPPEMENT
1 Edition - assemblage
org 0000H
LJMP DEBUT
DEBUT:
MOV A,#55H
MOV B,#0AAH
JMP $
END
-69-
0000 020003 2 LJMP DEBUT
0003 3 DEBUT:
0003 7455 4 MOV A,#55H
0005 75F0AA 5 MOV B,#0AAH
0008 80FE 6 JMP $
7
8 END
2 Simulation
- Double cliquer sur la ligne n°4. La ligne passe en jaune et le mot [BR 0] s’y affiche.
- Effectuer un Reset.
- Lancer l’exécution par Go.
Le programme s’arrête sur la ligne du BR. Le pas-à-pas peut continuer.
Pour enlever le point d’arrêt, double-cliquer sur la ligne du BR.
-70-
On se propose de réaliser des programmes de multiplication de 2 nombres de 8 bits
qui "émulent" la fonction MUL du 8051. Le multiplicande et le multiplicateur seront placés
dans A et B respectivement. Le résultat final devra être dans A et B (cf. instructions du 8051).
On développera tout d’abord un programme fonctionnant par "additions successives".
Puis, on réalisera un programme fonctionnant par "décalages" selon le principe donné ci-
après :
1010 multiplicande
x 1001 multiplicateur
------
1010 !
0000 ! résultats
0000 ! partiels
1010 !
------------
01011010 produit
On testera la validité des résultats obtenus et on évaluera les temps d’exécution des
opérations pour les 2 programmes réalisés.
Ces programmes peuvent être exécutés sur la maquette de TP. La seule modification à
leur apporter est de fixer l’adresse de départ dans la zone RAM (de 2000H à 3FFFH), par
exemple 3000H.
Le moniteur de mise au point décrit en annexe (CATMON32) permet le chargement
(Load) et le lancement de l’exécution (Goto) des programmes assemblés par l’environnement
Muvision.
-71-
Y
Ymax
O
Xmax X
Figure III-5
-72-
sinon Y est gardé
Y+32 --> Y ; si Y>T alors Y-32 --> Y
sinon Y est gardé
Y+16 --> Y ; si Y>T alors Y-16 --> Y
sinon Y est gardé
Y+08 --> Y ; si Y>T alors Y-08 --> Y
sinon Y est gardé
Y+04 --> Y ; si Y>T alors Y-04 --> Y
sinon Y est gardé
Y+02 --> Y ; si Y>T alors Y-02 --> Y
sinon Y est gardé
Y+01 --> Y ; si Y>T alors Y-01 --> Y
sinon Y est gardé
* Acquisition
* Visualisation
Après avoir transféré dans une zone mémoire (buffer) 256 échantillons du signal, on
peut visualiser en "continu" le contenu de cette zone et donc la forme du signal "numérisé".
Pour cela, on applique périodiquement sur les voies X et Y respectivement les valeurs
X et Y = buffer[X] pour X variant de 0 à 255, l'oscilloscope étant en mode X-Y.
-73-
- Tester le programme en appliquant à l'entrée E (SW1 étant en position AC) un signal de
quelques dizaines de hertz et d'amplitude crête à crête inférieure à 2V.
- Faire varier les fréquences du signal E et de BT. Interpréter les résultats obtenus.
* Couplage avec le PC
Il est possible de commander la carte 8051 à partir du PC grâce à des fonctions
disponibles en bibliothèque : on peut charger un programme, lancer son exécution et
transférer des données en lecture ou en écriture (cf. annexe).
- Développer un logiciel en C pour visualiser le signal numérisé par la carte 8051 sur l'écran
du micro-ordinateur à l'aide des fonctions graphiques disponibles.
-74-
BIBLIOGRAPHIE
-75-
ANNEXES
A1 - INSTRUCTIONS DU 8051
A2 - LANGAGE ASSEMBLEUR DU 8051
A3 - UTILISATION DU MONITEUR DE MISE AU POINT CATMON32
A4 - COMMANDES DU MONITEUR RESIDENT CATBUG
A5 - RESSOURCES UTILISEES PAR CATBUG
A6 - FONCTIONS C DE LA BIBLIOTHEQUE DE GESTION DE LA CARTE 8051
A7 - SCHEMA ELECTRIQUE CARTE 8051 1/2
A8 - SCHEMA ELECTRIQUE CARTE 8051 2/2
A9 - IMPLANTATION CARTE 8051
A10 - STRUCTURE D’UN FICHIER (.HEX)
A11 - LE CODE ASCII
A12 - 80C51 FAMILY ARCHITECTURE
A13 - 80C51 FAMILY PROGRAMMER’S GUIDE
A14 - NOTICE TECHNIQUE DU 8255
-76-
A1 - INSTRUCTIONS DU 8051
-77-
-78-
-79-
-80-
-81-
-82-
A2 - LANGAGE ASSEMBLEUR DU 8051
Le langage d'assemblage permet d'écrire le programme directement exécuté par le
microprocesseur sous une forme symbolique. C'est donc un traducteur d'un programme
symbolique dit programme source, en données binaires correspondant aux codes machine ou
programme objet.
Le programme source comprend un ensemble de lignes composées chacune de
plusieurs champs séparés par des espaces selon :
1 Etiquette
Elle permet de repérer l'adresse de la ligne. Elle est composée de lettres et de chiffres
(premier caractère = 1 lettre, longueur maximum =32 caractères) et doit se terminer par le
caractère : .
Exemples :
DEBUT:
FIN:
BOUCLE1:
Exemple :
;*******Ceci est un commentaire*******
2 Code Opération
3 Opérande
L'opérande représente une donnée ou une adresse sur laquelle porte l'opération. Il
regroupe d'une part le mode d'adressage, d'autre part une expression évaluable par
l'assembleur.
-83-
Le mode par défaut est le mode direct ou implicite. A chaque autre mode est associé
un symbole particulier.
- Forme numérique
Un nombre est interprété en décimal, sauf s'il est suivi d'un des caractères suivants :
H signifie : nombre hexadécimal,
B signifie : nombre binaire.
Exemples :
80H = 128 (décimal)
10101010B = 0AAH = 170 (décimal)
Remarque : si un nombre hexadécimal commence par une lettre (A-F), il faut le faire
précéder par le chiffre 0.
Exemple :
JMP $ ; Boucle sans fin !!!
- Forme symbolique
Un symbole est constitué comme une étiquette (sans le caractère :). Sa valeur doit
pouvoir être évaluée par l'assembleur. Nous verrons ultérieurement que des directives
permettent les affectations de valeurs numériques aux symboles.
Notons que l'opérande peut être calculé à partir d'opérations arithmétiques portant sur
des combinaisons entre valeurs numériques ou symboliques.
Les opérations reconnues sont :
+ : Addition
- : Soustraction
* : Multiplication
/ : Division entière
MOD : Module (reste de la division entière)
SHR : Décalage à droite
SHL : Décalage à gauche
NOT : Négation logique (complément)
AND : Et logique
OR : Ou (inclusif)
XOR : Ou (exclusif)
LOW : 8 bits de poids faible
HIGH : 8 bits de poids fort
-84-
EQ : Relation d’égalité (=)
NE : Relation de non égalité (<>)
GT : Relation de supériorité (>)
GE : Relation de supériorité ou égalité (>=)
LT : Relation d’infériorité (<)
LE : Relation d’infériorité ou égalité (<=)
4 Directives
ORG : établit l'adresse à partir de laquelle est implanté le programme qui suit.
-85-
A3 - UTILISATION DU MONITEUR DE MISE AU POINT CATMON32
Développé au Département d’Electronique de l’ENSEEIHT, ce logiciel permet de
commander la carte 8051. Ecrit en langage C++ (Borlandc 5.02), c’est une application
WINDOWS 32 bits qui assure la communication avec le logiciel résident sur la PROM
(CATBUG).
La fenêtre suivante regroupe les différentes commandes.
-86-
Attention : l’utilisation de points d’arrêt doit s’effectuer avec précaution. En effet, le principe
utilisé ici consiste à remplacer l’instruction du point d’arrêt par un appel à un sous-
programme du moniteur ; cet appel occupe 3 octets. Pour éviter tout problème, il est
préférable d’introduire des instructions de type NOP pour que l’instruction remplacée
"occupe" elle aussi 3 octets !
La fonction Dump permet de visualiser par blocs de 256 octets le contenu de la
mémoire interne ou externe. La fenêtre d’affichage est la suivante :
Le bouton I/E permet de choisir entre Interne et Externe. En mode Interne, seuls les
128 premiers octets sont significatifs. En mode Externe, on peut fixer l’adresse de début du
bloc qui est arrondie à un multiple de 16. Les boutons + et - permettent de se déplacer dans la
mémoire. La fonction Remp permet de remplir une zone mémoire externe entre une adresse
de départ et une adresse d’arrivée par une constante.
-87-
A4 - COMMANDES DU MONITEUR RESIDENT CATBUG
Les commandes élémentaires reconnues par CATBUG sont les suivantes :
MAAAA : lecture mémoire externe (AAAA : adresse en hexadécimal) ; le moniteur renvoie
DD# (DD : octet lu, # : fin de transaction).
IAA : lecture mémoire interne (AA : adresse en hexadécimal) ; le moniteur renvoie DD# (DD
: octet lu, # : fin de transaction).
FAADD : écriture mémoire interne (AA : adresse en hexadécimal, DD : donnée en
hexadécimal) ; le moniteur renvoie # (# : fin de transaction).
LXXXXYYYY112233... : écriture en mémoire externe d’un bloc compris entre l’adresse de
début XXXX et l’adresse de fin YYYY par les octets 112233... ; le moniteur renvoie # (# : fin
de transaction).
RC : lecture d’un registre (C : code du registre : A : accumulateur, B : registre B, H : DPH, L
: DPL, S : PSW, 0 : R0, 1 : R1, 2 : R2, 3 : R3, 4 : R4, 5 : R5, 6 : R6, 7 : R7, P : SP) ; le
moniteur renvoie DD# (DD : contenu du registre, # : fin de transaction).
WCDD : écriture d’un registre avec la valeur DD (C : code du registre : A : accumulateur, B :
registre B, H : DPH, L : DPL, S : PSW, 0 : R0, 1 : R1,2 : R2, 3 : R3, 4 : R4, 5 : R5,6 : R6, 7 :
R7, P : SP) ; le moniteur renvoie # (# : fin de transaction).
B1AAAA : Pose d’un point d’arrêt à l’adresse AAAA ; le moniteur renvoie # (# : fin de
transaction).
B1- : suppression du point d’arrêt ; le moniteur renvoie # (# : fin de transaction).
GAAAA : lancement d’un programme à l’adresse AAAA ; le moniteur renvoie # (# : fin de
transaction) si le programme utilisateur redonne le contrôle au moniteur (Point d’entrée :
0033). Si un point d’arrêt est rencontré, le moniteur renvoie BBBB# (BBBB : adresse du
point d’arrêt, # : fin de transaction).
SAAAA : lancement d’un programme à l’adresse AAAA en mode pas-à-pas ; le moniteur
renvoie BBBB# (BBBB : adresse suivante, # : fin de transaction).
Toutes ces commandes peuvent être envoyées par logiciel ou en mode émulation
"terminal".
-88-
A5 - RESSOURCES UTILISEES PAR CATBUG
Le moniteur CATBUG utilise des emplacements en mémoire interne et en mémoire
externe. Le tableau suivant montre l’utilisation de la mémoire interne :
0 1 2 3 4 5 6 7 8 9 A B C D E F
00 R R R R R R R R R R R R R R R R
10 R R R R R R R R R R R R R R R R
20
30 P -> -> -> -> -> -> ->
40
50
60 M M M M M M M M
70 M M M M M M M M M M M M M M M M
0 1 2 3 4 5 6 7 8 9 A B C D E F
2000 X X X X X X U U U
2010 U U U U U U
2020 U U U U U U
2030 P P P
Remarques : - lors d’un Reset, les vecteurs modifiables par l’utilisateur (U) sont initialisés
par défaut avec l’instruction RETI (23H),
- le vecteur associé à l’interruption INT0 (2003H) est contrôlé par Catbug et
utilisé pour le pas-à-pas. Il ne faut donc pas le modifier dans la phase de mise au point !
-89-
0036 LJMP DELAY // Temporisation de A * 1 ms
0039 LJMP SERIN // Entrée d’un caractère dans A
003C LJMP GETC // Entrée d’un caractère et conversion minuscule-majuscule (A)
003F LJMP PUTC // Sortie d’un caractère dans A
0042 LJMP PUTS // Sortie d’une chaîne de caractère pointée par DPTR et terminée
// par 0
0045 LJMP ASC2HEX // Conversion ASCII-Hexadécimal (A)
0048 LJMP HEX2ASC // Conversion Hexadécimal-ASCII (A)
004B LJMP RDHEX // Entrée d’un octet à partir de 2 caractères hexa (A)
004E LJMP WRBYTE // Sortie d’un octet sous forme de 2 caractères hexa (A)
0051 LJMP TESTSERIN // Test de réception d’un caractère : C=0 : non ; C=1 : oui
-90-
A6 - FONCTIONS C DE LA BIBLIOTHEQUE DE GESTION DE LA CARTE 8051
Les fonctions C sont contenues dans le fichier 8051drv.obj (version DOS) ou
8051dr32.obj (version Windows 32 bits) et leurs prototypes dans le fichier 8051drv.h
(version DOS) ou 8051dr32.h (version Windows 32 bits). Les programmes appelant ces
fonctions doivent comprendre la directive : #include "8051drv.h" ou #include "8051dr32.h"
selon le cas.
ADR_IN
Fonction : Lecture d’une adresse sur deux octets de la carte 8051.
Prototype : int Adr_in(unsigned int *adr)
Paramètres en entrée : pointeur sur l’adresse à lire
Valeur retournée : 0 : OK, ESC : erreur.
BUF_OUT
Fonction : Sortie du contenu d’un buffer de caractères vers la carte 8051.
Prototype : int Buf_out(char buf[])
Paramètres en entrée : buffer de caractères
Valeur retournée : 0 : OK, ESC : erreur.
BYTE_IN
Fonction : Lecture d’une donnée sur un octet de la carte 8051.
Prototype : int Byte_in(unsigned int *data)
Paramètres en entrée : pointeur sur la donnée à lire
Valeur retournée : 0 : OK, ESC : erreur.
CIN
Fonction : Entrée d’un caractère émis par la carte 8051.
Prototype : int Cin(void)
Paramètres en entrée : aucun
Valeur retournée : caractère, ESC : erreur.
COUT
Fonction : Sortie d’un caractère vers la carte 8051.
Prototype : int Cout(int valeur)
Paramètres en entrée : valeur du caractère
Valeur retournée : 0 : OK, ESC : erreur.
DOWNLOAD
Fonction : Chargement d’un programme dans la carte 8051.
Prototype : int Download(char FileName[],unsigned int *adr1)
Paramètres en entrée : nom du fichier (.hex), pointeur sur l’adresse de début de chargement
Valeur retournée : 0 : OK, 1 : erreur.
ECR_MEMINT
Fonction : Ecriture d’un octet en mémoire interne de la carte 8051.
Prototype : int Ecr_memint(unsigned int adresse,unsigned int donnee)
Paramètres en entrée : adresse, donnée
Valeur retournée : 0 : OK, ESC : erreur.
-91-
ECR_MEMEXT
Fonction : Ecriture d’un octet en mémoire externe de la carte 8051.
Prototype : int Ecr_memext(unsigned int adresse,unsigned int donnee)
Paramètres en entrée : adresse, donnée
Valeur retournée : 0 : OK, ESC : erreur.
GOTO1
Fonction : Lancement d’un programme de la carte 8051.
Prototype : int Goto1(unsigned int *adr)
Paramètres en entrée : pointeur sur l’adresse de début du programme chargé
Valeur retournée : 0 : OK, ESC : erreur.
LEC_MEMINT
Fonction : Lecture d’un octet en mémoire interne de la carte 8051.
Prototype : int Lec_memint(unsigned int adresse,unsigned int *data)
Paramètres en entrée : adresse, pointeur sur la donnée
Valeur retournée : 0 : OK, ESC : erreur.
LEC_MEMEXT
Fonction : Lecture d’un octet en mémoire externe de la carte 8051.
Prototype : int Lec_memext(unsigned int adresse,unsigned int *data)
Paramètres en entrée : adresse, pointeur sur la donnée
Valeur retournée : 0 : OK, ESC : erreur.
RESET1
Fonction : Initialisation de la carte 8051 et des PIA de communication.
Prototype : int Reset1(void)
Paramètres en entrée : aucun
Valeur retournée : 0 : OK, 1 : erreur.
TEST_CIN
Fonction : Test de disponibilité d’un caractère émis par la carte 8051.
Prototype : int Test_cin(void)
Paramètres en entrée : aucun
Valeur retournée : 0 : pas de caractère, 1 caractère émis.
-92-
A7 - SCHEMA ELECTRIQUE CARTE 8051 1/2
-93-
A8 - SCHEMA ELECTRIQUE CARTE 8051 2/2
-94-
A9 - IMPLANTATION CARTE 8051
-95-
A10 - STRUCTURE D’UN FICHIER (.HEX)
The 8-bit Intel Hex File Format is a printable ASCII format consisting of one or more
data records followed by an end of file record. Each record consists of one line of
information. Data records may appear in any order. Address and data values are represented
as 4 or 2 hexadecimal digit values.
Record Format
:LLAAAARRDDDD......DDDDCC
Example:
:06010000010203040506E4
:00000001FF
The first line in the above example Intel Hex file is a data record addressed at location
100H with data values 1 to 6. The second line is the end of file record.
-96-
A11 - LE CODE ASCII
-97-
A12 - 80C51 FAMILY ARCHITECTURE
-98-
Philips Semiconductors
80C51 ARCHITECTURE The interrupt service locations are spaced at 8-byte intervals: 0003H
for External Interrupt 0, 000BH for Timer 0, 0013H for External
Interrupt 1, 001BH for Timer 1, etc. If an interrupt service routine is
MEMORY ORGANIZATION short enough (as is often the case in control applications), it can
All 80C51 devices have separate address spaces for program and reside entirely within that 8-byte interval. Longer service routines
data memory, as shown in Figures 1 and 2. The logical separation of can use a jump instruction to skip over subsequent interrupt
program and data memory allows the data memory to be accessed locations, if other interrupts are in use.
by 8-bit addresses, which can be quickly stored and manipulated by
an 8-bit CPU. Nevertheless, 16-bit data memory addresses can also The lowest 4k bytes of Program Memory can either be in the on-chip
be generated through the DPTR register. ROM or in an external ROM. This selection is made by strapping the
EA (External Access) pin to either VCC, or VSS. In the 80C51, if the
Program memory (ROM, EPROM) can only be read, not written to. EA pin is strapped to VCC, then the program fetches to addresses
There can be up to 64k bytes of program memory. In the 80C51, the 0000H through 0FFFH are directed to the internal ROM. Program
lowest 4k bytes of program are on-chip. In the ROMless versions, all fetches to addresses 1000H through FFFFH are directed to external
program memory is external. The read strobe for external program ROM.
memory is the PSEN (program store enable).
If the EA pin is strapped to VSS, then all program fetches are
Data Memory (RAM) occupies a separate address space from directed to external ROM. The ROMless parts (8031, 80C31, etc.)
Program Memory. In the 80C51, the lowest 128 bytes of data must have this pin externally strapped to VSS to enable them to
memory are on-chip. Up to 64k bytes of external RAM can be execute from external Program Memory.
addressed in the external Data Memory space. In the ROMless
The read strobe to external ROM, PSEN, is used for all external
version, the lowest 128 bytes are on-chip. The CPU generates read
program fetches. PSEN is not activated for internal program fetches.
and write signals, RD and WR, as needed during external Data
Memory accesses. The hardware configuration for external program execution is shown
in Figure 4. Note that 16 I/O lines (Ports 0 and 2) are dedicated to
External Program Memory and external Data Memory may be
bus functions during external Program Memory fetches. Port 0 (P0
combined if desired by applying the RD and PSEN signals to the
in Figure 4) serves as a multiplexed address/data bus. It emits the
inputs of an AND gate and using the output of the gate as the read
low byte of the Program Counter (PCL) as an address, and then
strobe to the external Program/Data memory.
goes into a float state awaiting the arrival of the code byte from the
Program Memory. During the time that the low byte of the Program
Program Memory
Counter is valid on Port 0, the signal ALE (Address Latch Enable)
Figure 3 shows a map of the lower part of the Program Memory.
clocks this byte into an address latch. Meanwhile, Port 2 (P2 in
After reset, the CPU begins execution from location 0000H. As
Figure 4) emits the high byte of the Program Counter (PCH). Then
shown in Figure 3, each interrupt is assigned a fixed location in
PSEN strobes the EPROM and the code byte is read into the
Program Memory. The interrupt causes the CPU to jump to that
microcontroller.
location, where it commences execution of the service routine.
External Interrupt 0, for example, is assigned to location 0003H. If Program Memory addresses are always 16 bits wide, even though
External Interrupt 0 is going to be used, its service routine must the actual amount of Program Memory used may be less than 64k
begin at location 0003H. If the interrupt is not going to be used, its bytes. External program execution sacrifices two of the 8-bit ports,
service location is available as general purpose Program Memory. P0 and P2, to the function of addressing the Program Memory.
External
Interrupts
Timer 1
Interrupt 4k 128 Counter
Control Inputs
ROM RAM Timer 0
CPU
TXD RXD
P0 P2 P1 P3
Address/Data
SU00458
March 1995 1
Philips Semiconductors
FFFFH: FFFFH:
External
Internal
0FFFH FFH:
EA = 0 EA = 1
External Internal
0000 00
PSEN RD WR
SU00459
80C51 EPROM
0023H
P0
001BH
8 Bytes EA
Interrupt 0013H
Locations
P2
0003H
PSEN OE
Reset 0000H
SU00460 SU00461
Figure 3. 80C51 Program Memory Figure 4. Executing from External Program Memory
March 1995 2
Philips Semiconductors
Internal Data Memory addresses are always one byte wide, which The next 16 bytes above the register banks form a block of
implies an address space of only 256 bytes. However, the bit-addressable memory space. The 80C51 instruction set includes
addressing modes for internal RAM can in fact accommodate 384 a wide selection of single-bit instructions, and the 128 bits in this
bytes, using a simple trick. Direct addresses higher than 7FH area can be directly addressed by these instructions. The bit
access one memory space, and indirect addresses higher than 7FH addresses in this area are 00H through 7FH.
access a different memory space. Thus Figure 6 shows the Upper
All of the bytes in the Lower 128 can be accessed by either direct or
128 and SFR space occupying the same block of addresses, 80H
indirect addressing. The Upper 128 (Figure 8) can only be accessed
through FFH, although they are physically separate entities.
by indirect addressing.
The Lower 128 bytes of RAM are present in all 80C51 devices as
Figure 9 gives a brief look at the Special Function Register (SFR)
mapped in Figure 7. The lowest 32 bytes are grouped into 4 banks
space. SFRs include the Port latches, timers, peripheral controls,
of 8 registers. Program instructions call out these registers as R0
etc. These registers can only be accessed by direct addressing.
through R7. Two bits in the Program Status Word (PSW) select
Sixteen addresses in SFR space are both byte- and bit-addressable.
which register bank is in use. This allows more efficient use of code
The bit-addressable SFRs are those whose address ends in 0H or 8H.
space, since register instructions are shorter than instructions that
use direct addressing.
Data
P0 FFH FFH
RAM Accessible Accessible
EA VCC Upper by Indirect by Direct
80C51 128 Addressing Addressing
with Only
Internal Latch
ROM 80H 80H
ALE 7FH
ADDR Accessible
by Direct Ports,
Lower Status and
128 and Indirect
Addressing Control Bits,
Special Timer,
P3 P2 0 Function Registers,
RD Registers Stack Pointer,
WR I/O Accumulator
Page WE OE
(Etc.)
Bits
SU00462 SU00463
7FH FFH
2FH
Bank
Select Bit-Addressable Space No Bit-Addressable
Bits in (Bit Addresses 0-7F) Spaces
PSW
20H
1FH
11
18H
17H
10
10H 4 Banks of
8 Registers
0FH R0-R7
01
08H
07H Reset Value of
00 Stack Pointer
0 80H
SU00464 SU00465
Figure 7. Lower 128 Bytes of Internal RAM Figure 8. Upper 128 Bytes of Internal RAM
March 1995 3
Philips Semiconductors
FFH .
. Register-Mapped Ports
.
E0H ACC
.
. Addresses that end in 0H or 8H
. are also
bit-addressable.
B0H Port 3
.
.
.
- Port Pins
A0H Port 2 - Accumulator
- PSW
(Etc.)
90H Port 1
.
.
.
80H Port 0
SU00466
CY AC F0 RS1 RS0 OV P
PSW 7 PSW 0
Carry flag receives carry out Parity of accumulator set
from bit 7 of ALU operands by hardware to 1 if it contains
an odd number of 1s; otherwise
it is reset to 0.
PSW 6 PSW 1
Auxiliary carry flag receives carry out from bit 3 User-definable flag
of addition operands.
PSW 5 PSW 2
General purpose status flag Overflow flag set by
arithmetic operations
PSW 4 PSW 3
Register bank select bit 1 Register bank select bit 0
SU00467
80C51 FAMILY INSTRUCTION SET RAM locations as R0 through R7. The selection of which of the four
The 80C51 instruction set is optimized for 8-bit control applications. is being referred to is made on the basis of the RS0 and RS1 at
It provides a variety of fast addressing modes for accessing the execution time.
internal RAM to facilitate byte operations on small data structures. The Parity bit reflects the number of 1s in the Accumulator: P = 1 if
The instruction set provides extensive support for one-bit variables the Accumulator contains an odd number of 1s, and P = 0 if the
as a separate data type, allowing direct bit manipulation in control Accumulator contains an even number of 1s. Thus the number of 1s
and logic systems that require Boolean processing. in the Accumulator plus P is always even. Two bits in the PSW are
uncommitted and may be used as general purpose status flags.
Program Status Word
The Program Status Word (PSW) contains several status bits that Addressing Modes
reflect the current state of the CPU. The PSW, shown in Figure 10, The addressing modes in the 80C51 instruction set are as follows:
resides in the SFR space. It contains the Carry bit, the Auxiliary
Carry (for BCD operations), the two register bank select bits, the Direct Addressing
Overflow flag, a Parity bit, and two user-definable status flags. In direct addressing the operand is specified by an 8-bit address
field in the instruction. Only internal Data RAM and SFRs can be
The Carry bit, other than serving the function of a Carry bit in
directly addressed.
arithmetic operations, also serves as the “Accumulator” for a
number of Boolean operations.
The bits RS0 and RS1 are used to select one of the four register
banks shown in Figure 7. A number of instructions refer to these
March 1995 4
Philips Semiconductors
March 1995 5
Philips Semiconductors
The addressing modes that can be used to access the <byte> Data Transfers
operand are listed in Table 2.
Internal RAM
The ANL A, <byte> instruction may take any of the forms: Table 3 shows the menu of instructions that are available for moving
ANL A,7FH (direct addressing) data around within the internal memory spaces, and the addressing
ANL A,@R1 (indirect addressing) modes that can be used with each one. With a 12MHz clock, all of
ANL A,R6 (register addressing) these instructions execute in either 1 or 2µs.
ANL A,#53H (immediate constant)
The MOV <dest>, <src> instruction allows data to be transferred
All of the logical instructions that are Accumulator-specific execute between any two internal RAM or SFR locations without going
in 1µs (using a 12MHz clock). The others take 2µs. through the Accumulator. Remember, the Upper 128 bytes of data
Note that Boolean operations can be performed on any byte in the RAM can be accessed only by indirect addressing, and SFR space
internal Data Memory space without going through the Accumulator. only by direct addressing.
The XRL <byte>, #data instruction, for example, offers a quick and Note that in 80C51 devices, the stack resides in on-chip RAM, and
easy way to invert port bits, as in XRL P1, #OFFH. grows upwards. The PUSH instruction first increments the Stack
If the operation is in response to an interrupt, not using the Pointer (SP), then copies the byte into the stack. PUSH and POP
Accumulator saves the time and effort to push it onto the stack in the use only direct addressing to identify the byte being saved or
service routine. restored, but the stack itself is accessed by indirect addressing
using the SP register. This means the stack can go into the Upper
The Rotate instructions (RL, A, RLC A, etc.) shift the Accumulator 1 128 bytes of RAM, if they are implemented, but not into SFR space.
bit to the left or right. For a left rotation, the MSB rolls into the LSB
position. For a right rotation, the LSB rolls into the MSB position. The Upper 128 bytes of RAM are not implemented in the 80C51 nor
in its ROMless or EPROM counterparts. With these devices, if the
The SWAP A instruction interchanges the high and low nibbles SP points to the Upper 128, PUSHed bytes are lost, and POPed
within the Accumulator. This is a useful operation in BCD bytes are indeterminate.
manipulations. For example, if the Accumulator contains a binary
number which is known to be less than 100, it can be quickly The Data Transfer instructions include a 16-bit MOV that can be
converted to BCD by the following code: used to initialize the Data Pointer (DPTR) for look-up tables in
Program Memory, or for 16-bit external Data Memory accesses.
March 1995 6
Philips Semiconductors
Table 3. Data Transfer Instructions that Access Internal Data Memory Space
MNEMONIC OPERATION ADDRESSING MODES EXECUTION
DIR IND REG IMM TIME (µs)
MOV A,<src> A = <src> X X X X 1
MOV <dest>,A <dest> = A X X X 1
MOV <dest>,<src> <dest> = <src> X X X X 2
MOV DPTR,#data16 DPTR = 16-bit immediate constant X 2
PUSH <src> INC SP:MOV“@SP”,<src> X 2
POP <dest> MOV <dest>,“@SP”:DEC SP X 2
XCH A,<byte> ACC and <byte> exchange data X X X 1
XCHD A,@Ri ACC and @Ri exchange low nibbles X 1
The XCH A, <byte> instruction causes the Accumulator and leaves the last byte, location 2EH, holding the last two digits of the
addressed byte to exchange data. The XCHD A, @Ri instruction is shifted number. The pointers are decremented, and the loop is
similar, but only the low nibbles are involved in the exchange. repeated for location 2DH. The CJNE instruction (Compare and
Jump if Not Equal) is a loop control that will be described later. The
To see how XCH and XCHD can be used to facilitate data
loop executed from LOOP to CJNE for R1 = 2EH, 2DH, 2CH, and
manipulations, consider first the problem of shifting an 8-digit BCD
2BH. At that point the digit that was originally shifted out on the right
number two digits to the right. Figure 11 shows how this can be
has propagated to location 2AH. Since that location should be left
done using direct MOVs, and for comparison how it can be done
with 0s, the lost digit is moved to the Accumulator.
using XCH instructions. To aid in understanding how the code
works, the contents of the registers that are holding the BCD External RAM
number and the content of the Accumulator are shown alongside Table 4 shows a list of the Data Transfer instructions that access
each instruction to indicate their status after the instruction has been external Data Memory. Only indirect addressing can be used. The
executed. choice is whether to use a one-byte address, @Ri, where Ri can be
After the routine has been executed, the Accumulator contains the either R0 or R1 of the selected register bank, or a two-byte address,
two digits that were shifted out on the right. Doing the routine with @DPTR. The disadvantage to using 16-bit addresses if only a few k
direct MOVs uses 14 code bytes and 9µs of execution time bytes of external RAM are involved is that 16-bit addresses use all 8
(assuming a 12MHz clock). The same operation with XCHs uses bits of Port 2 as address bus. On the other hand, 8-bit addresses
only 9 bytes and executes almost twice as fast. allow one to address a few bytes of RAM, as shown in Figure 5,
without having to sacrifice all of Port 2. All of these instructions
To right-shift by an odd number of digits, a one-digit shift must be execute in 2 µs, with a 12MHz clock.
executed.
Note that in all external Data RAM accesses, the Accumulator is
Figure 12 shows a sample of code that will right-shift a BCD number always either the destination or source of the data.
one digit, using the XCHD instruction. Again, the contents of the
registers holding the number and of the Accumulator are shown The read and write strobes to external RAM are activated only
alongside each instruction. during the execution of a MOVX instruction. Normally these signals
are inactive, and in fact if they’re not going to be used at all, their
First, pointers R1 and R0 are set up to point to the two bytes pins are available as extra I/O lines.
containing the last four BCD digits. Then a loop is executed which
2A 2B 2C 2D 2E ACC 2A 2B 2C 2D 2E ACC
CLR A 00 12 34 56 78 00
XCH A,2BH 00 00 34 56 78 12 loop for R1 = 2DH: 00 12 38 45 67 45
XCH A,2CH 00 00 12 56 78 34 loop for R1 = 2CH: 00 18 23 45 67 23
XCH A,2DH 00 00 12 34 78 56 loop for R1 = 2BH: 08 01 23 45 67 01
XCH A2EH 00 00 12 34 56 78
SU00468 SU00469
Figure 11. Shifting a BCD Number Two Digits to the Right Figure 12. Shifting a BCD Number One Digit to the Right
March 1995 7
Philips Semiconductors
Table 4. 80C51 Data Transfer Instructions that Access External Data Memory Space
ADDRESS MNEMONIC OPERATION EXECUTION
WIDTH TIME (µs)
8 bits MOVX A,@Ri Read external RAM @Ri 2
8 bits MOVX @Ri,A Write external RAM @ Ri 2
16 bits MOVX A,@DPTR Read external RAM @ DPTR 2
16 bits MOVX @DPTR,A Write external RAM @ DPTR 2
Lookup Tables Note how easily an internal flag can be moved to a port pin:
Table 5 shows the two instructions that are available for reading MOV C,FLAG
lookup tables in Program Memory. Since these instructions access MOV P1.0,C
only Program Memory, the lookup tables can only be read, not
In this example, FLAG is the name of any addressable bit in the
updated.
Lower 128 or SFR space. An I/O line (the LSB of Port 1, in this
If the table access is to external Program Memory, then the read case) is set or cleared depending on whether the flag bit is 1 or 0.
strobe is PSEN.
The Carry bit in the PSW is used as the single-bit Accumulator of
The mnemonic is MOVC for “move constant.” The first MOVC the Boolean processor. Bit instructions that refer to the Carry bit as
instruction in Table 5 can accommodate a table of up to 256 entries C assemble as Carry-specific instructions (CLR C, etc.). The Carry
numbered 0 through 255. The number of the desired entry is loaded bit also has a direct address, since it resides in the PSW register,
into the Accumulator, and the Data Pointer is set up to point to the which is bit-addressable.
beginning of the table. Then:
Note that the Boolean instruction set includes ANL and ORL
MOVC A,@A+DPTR
operations, but not the XRL (Exclusive OR) operation. An XRL
copies the desired table entry into the Accumulator. operation is simple to implement in software. Suppose, for example,
it is required to form the Exclusive OR of two bits:
The other MOVC instruction works the same way, except the
C = bit1 .XRL. bit2
Program Counter (PC) is used as the table base, and the table is
accessed through a subroutine. First the number of the desired The software to do that could be as follows:
entry is loaded into the Accumulator, and the subroutine is called: MOV C,bit1
MOV A,ENTRY NUMBER JNB bit2,OVER
CALL TABLE CPL C
OVER: (continue)
The subroutine “TABLE” would look like this:
TABLE: MOVC A,@A+PC First, bit1 is moved to the Carry. If bit2 = 0, then C now contains the
RET correct result. That is, bit1 .XRL. bit2 = bit1 if bit2 = 0. On the other
hand, if bit2 = 1, C now contains the complement of the correct
The table itself immediately follows the RET (return) instruction in
result. It need only be inverted (CPL C) to complete the operation.
Program Memory. This type of table can have up to 255 entries,
numbered 1 through 255. Number 0 cannot be used, because at the This code uses the JNB instruction, one of a series of bit-test
time the MOVC instruction is executed, the PC contains the address instructions which execute a jump if the addressed bit is set (JC, JB,
of the RET instruction. An entry numbered 0 would be the RET JBC) or if the addressed bit is not set (JNC, JNB). In the above
opcode itself. case, bit2 is being tested, and if bit2 = 0, the CPL C instruction is
jumped over.
Boolean Instructions
80C51 devices contain a complete Boolean (single-bit) processor. JBC executes the jump if the addressed bit is set, and also clears
The internal RAM contains 128 addressable bits, and the SFR the bit. Thus a flag can be tested and cleared in one operation. All
space can support up to 128 addressable bits as well. All of the port the PSW bits are directly addressable, so the Parity bit, or the
lines are bit-addressable, and each one can be treated as a general purpose flags, for example, are also available to the bit-test
separate single-bit port. The instructions that access these bits are instructions.
not just conditional branches, but a complete menu of move, set, Relative Offset
clear, complement, OR, and AND instructions. These kinds of bit The destination address for these jumps is specified to the
operations are not easily obtained in other architectures with any assembler by a label or by an actual address in Program memory.
amount of byte-oriented software. However, the destination address assembles to a relative offset
The instruction set for the Boolean processor is shown in Table 6. All byte. This is a signed (two’s complement) offset byte which is added
bit accesses are by direct addressing. to the PC in two’s complement arithmetic if the jump is executed.
The range of the jump is therefore –128 to +127 Program Memory
Bit addresses 00H through 7FH are in the Lower 128, and bit bytes relative to the first byte following the instruction.
addresses 80H through FFH are in SFR space.
March 1995 8
Philips Semiconductors
Jump Instructions In all cases the programmer specifies the destination address to the
Table 7 shows the list of unconditional jumps with execution time for assembler in the same way: as a label or as a 16-bit constant. The
a 12MHz clock. assembler will put the destination address into the correct format for
the given instruction. If the format required by the instruction will not
The table lists a single “JMP addr” instruction, but in fact there are support the distance to the specified destination address, a
three SJMP, LJMP, and AJMP, which differ in the format of the “Destination out of range” message is written into the List file.
destination address. JMP is a generic mnemonic which can be used
if the programmer does not care which way the jump is encoded. The JMP @A+DPTR instruction supports case jumps. The
destination address is computed at execution time as the sum of the
The SJMP instruction encodes the destination address as a relative 16-bit DPTR register and the Accumulator. Typically, DPTR is set up
offset, as described above. The instruction is 2 bytes long, with the address of a jump table. In a 5-way branch, for example, an
consisting of the opcode and the relative offset byte. The jump integer 0 through 4 is loaded into the Accumulator. The code to be
distance is limited to a range of –128 to +127 bytes relative to the executed might be as follows:
instruction following the SJMP. MOV DPTR,#JUMP TABLE
The LJMP instruction encodes the destination address as a 16-bit MOV A,INDEX_NUMBER
constant. The instruction is 3 bytes long, consisting of the opcode RL A
and two address bytes. The destination address can be anywhere in JMP @A+DPTR
the 64k Program Memory space. The RL A instruction converts the index number (0 through 4) to an
The AJMP instruction encodes the destination address as an 11-bit even number on the range 0 through 8, because each entry in the
constant. The instruction is 2 bytes long, consisting of the opcode, jump table is 2 bytes long:
which itself contains 3 of the 11 address bits, followed by another JUMP TABLE:
byte containing the low 8 bits of the destination address. When the AJMP CASE 0
instruction is executed, these 11 bits are simply substituted for the AJMP CASE 1
low 11 bits in the PC. The high 5 bits stay the same. Hence the AJMP CASE 2
destination has to be within the same 2k block as the instruction AJMP CASE 3
following the AJMP. AJMP CASE 4
March 1995 9
Philips Semiconductors
Table 7 shows a single “CALL addr” instruction, but there are two of The CJNE instruction (Compare and Jump if Not Equal) can also be
them, LCALL and ACALL, which differ in the format in which the used for loop control as in Figure 12. Two bytes are specified in the
subroutine address is given to the CPU. CALL is a generic operand field of the instruction. The jump is executed only if the two
mnemonic which can be used if the programmer does not care bytes are not equal. In the example of Figure 12, the two bytes were
which way the address is encoded. data in R1 and the constant 2AH. The initial data in R1 was 2EH.
Every time the loop was executed, R1 was decremented, and the
The LCALL instruction uses the 16-bit address format, and the
looping was to continue until the R1 data reached 2AH.
subroutine can be anywhere in the 64k Program Memory space.
The ACALL instruction uses the 11-bit format, and the subroutine Another application of this instruction is in “greater than, less than”
must be in the same 2k block as the instruction following the comparisons. The two bytes in the operand field are taken as
ACALL. unsigned integers. If the first is less than the second, then the Carry
bit is set (1). If the first is greater than or equal to the second, then
In any case, the programmer specifies the subroutine address to the
the Carry bit is cleared.
assembler in the same way: as a label or as a 16-bit constant. The
assembler will put the address into the correct format for the given CPU Timing
instructions. All 80C51 microcontrollers have an on-chip oscillator which can be
Subroutines should end with a RET instruction, which returns used if desired as the clock source for the CPU. To use the on-chip
execution to the instruction following the CALL. oscillator, connect a crystal or ceramic resonator between the
XTAL1 and XTAL2 pins of the microcontroller, and capacitors to
RETI is used to return from an interrupt service routine. The only ground as shown in Figure 13.
difference between RET and RETI is that RETI tells the interrupt
control system that the interrupt in progress is done. If there is no Examples of how to drive the clock with an external oscillator are
interrupt in progress at the time RETI is executed, then the RETI is shown in Figure 14. Note that in the NMOS devices (8051, etc.) the
functionally identical to RET. signal at the XTAL2 pin actually drives the internal clock generator.
In the CMOS devices (80C51, etc.), the signal at the XTAL1 pin
Table 8 shows the list of conditional jumps available to the 80C51 drives the internal clock generator. The internal clock generator
user. All of these jumps specify the destination address by the defines the sequence of states that make up the 80C51 machine
relative offset method, and so are limited to a jump distance of –128 cycle.
to +127 bytes from the instruction following the conditional jump
instruction. Important to note, however, the user specifies to the
assembler the actual destination address the same way as the other
jumps: as a label or a 16-bit constant. HMOS or
CMOS
There is no Zero bit in the PSW. The JZ and JNZ instructions test
the Accumulator data for that condition.
XTAL2
Quartz crystal
The DJNZ instruction (Decrement and Jump if Not Zero) is for loop or ceramic
C1
control. To execute a loop N times, load a counter byte with N and resonator
terminate the loop with a DJNZ to the beginning of the loop, as C2
shown below for N = 10. XTAL1
MOV COUNTER,#10
LOOP: (begin loop)
• VSS
•
• SU00470
(end loop)
Figure 13. Using the On-Chip Oscillator
DJNZ COUNTER,LOOP
(continue)
March 1995 10
Philips Semiconductors
External
XTAL2 clock XTAL2 (NC) XTAL2
signal
External External
clock XTAL1 XTAL1 clock XTAL1
signal signal
Machine Cycles The fetch/execute sequences are the same whether the Program
A machine cycle consists of a sequence of 6 states, numbered S1 Memory is internal or external to the chip. Execution times do not
through S6. Each state time lasts for two oscillator periods. Thus a depend on whether the Program Memory is internal or external.
machine cycle takes 12 oscillator periods or 1µs if the oscillator Figure 16 shows the signals and timing involved in program fetches
frequency is 12MHz. when the Program Memory is external. If Program Memory is
Each state is divided into a Phase 1 half and a Phase 2 half. external, then the Program Memory read strobe PSEN is normally
Figure 15 shows that fetch/execute sequences in states and phases activated twice per machine cycle, as shown in Figure 16a. If an
for various kinds of instructions. Normally two program fetches are access to external Data Memory occurs, as shown in Figure 16b,
generated during each machine cycle, even if the instruction being two PSENs are skipped, because the address and data bus are
executed doesn’t require it. If the instruction being executed doesn’t being used for the Data Memory access.
need more code bytes, the CPU simply ignores the extra fetch, and Note that a Data Memory bus cycle takes twice as much time as a
the Program Counter is not incremented. Program Memory bus cycle. Figure 16 shows the relative timing of
Execution of a one-cycle instruction (Figures 15a and 15b) begins the addresses being emitted at Ports 0 and 2, and of ALE and
during State 1 of the machine cycle, when the opcode is latched into PSEN. ALE is used to latch the low address byte from P0 into the
the Instruction Register. A second fetch occurs during S4 of the address latch.
same machine cycle. Execution is complete at the end of State 6 of When the CPU is executing from internal Program Memory, PSEN is
this machine cycle. not activated, and program addresses are not emitted. However,
The MOVX instructions take two machine cycles to execute. No ALE continues to be activated twice per machine cycle and so it is
program fetch is generated during the second cycle of a MOVX available as a clock output signal. Note, however, that one ALE is
instruction. This is the only time program fetches are skipped. The skipped during the execution of the MOVX instruction.
fetch/execute sequence for MOVX instructions is shown in Figure
15d.
March 1995 11
Philips Semiconductors
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6 S1
Osc. P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2
(XTAL2)
ALE
Read next
Read opcode. opcode Read next opcode again.
(discard).
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
ADDR DATA
March 1995 12
Philips Semiconductors
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
ALE
PSEN
RD
P2 PCH out PCH out PCH out PCH out PCH out PCH out
P0 INST PCL INST PCL INST PCL INST PCL INST PCL
in out in out in out in out in out
PCL out PCL out PCL out PCL out PCL out
Valid Valid Valid Valid Valid
a. Without a MOVX
Cycle 1 Cycle 2
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
ALE
PSEN
RD
P2 PCH out PCH out DPH out or P2 out PCH out PCH out
b. With a MOVX
SU00473
Figure 16. Bus Cycles in 80C51 Family Devices Executing from External Program Memory
March 1995 13
Philips Semiconductors
SU00474 SU00475
Figure 17. Interrupt Enable (IE) Register Figure 18. Interrupt Priority (IP) Register
High Priority
IE Register IP Register Interrupt
0
INT0 IT0 IE0
Interrupt Pol-
ling
TF0
Sequence
0
IE1
INT1 IT1
TF1
RI
TI
March 1995 14
Philips Semiconductors
Interrupt Structure noted (Figure 3), the service routine for each interrupt begins at a
The 80C51 and its ROMless and EPROM versions have 5 interrupt fixed location.
sources: 2 external interrupts, 2 timer interrupts, and the serial port Only the Program Counter is automatically pushed onto the stack,
interrupt. not the PSW or any other register. Having only the PC automatically
What follows is an overview of the interrupt structure for the device. saved allows the programmer to decide how much time should be
More detailed information for specific members of the 80C51 spent saving other registers. This enhances the interrupt response
derivative family is provided in later chapters of this user’s guide. time, albeit at the expense of increasing the programmer’s burden of
responsibility. As a result, many interrupt functions that are typical in
Interrupt Enables control applications toggling a port pin for example, or reloading a
Each interrupt source can be individually enabled or disabled by timer, or unloading a serial buffer can often be completed in less
setting or clearing a bit in the SFR named IE (Interrupt Enable). This time than it takes other architectures to complete.
register also contains a global disable bit, which can be cleared to
disable all interrupts at once. Figure 17 shows the IE register. Simulating a Third Priority Level in Software
Some applications require more than two priority levels that are
Interrupt Priorities provided by on-chip hardware in 80C51 devices. In these cases,
Each interrupt source can also be individually programmed to one of relatively simple software can be written to produce the same effect
two priority levels by setting or clearing a bit in the SFR named IP as a third priority level. First, interrupts that are to have higher
(Interrupt Priority). Figure 18 shows the IP register. A low-priority priority than 1 are assigned to priority 1 in the Interrupt Priority (IP)
interrupt can be interrupted by a high-priority interrupt, but not by register. The service routines for priority 1 interrupts that are
another low-priority interrupt. A high-priority interrupt can’t be supposed to be interruptable by priority 2 interrupts are written to
interrupted by any other interrupt source. include the following code:
If two interrupt requests of different priority levels are received PUSH IE
simultaneously, the request of higher priority is serviced. If interrupt MOV IE,#MASK
requests of the same priority level are received simultaneously, an CALL LABEL
internal polling sequence determines which request is serviced. ************************
Thus within each priority level there is a second priority structure (execute service routine)
determined by the polling sequence. Figure 19 shows how the IE *************************
and IP registers and the polling sequence work to determine which if POP IE
any interrupt will be serviced. RET
In operation, all the interrupt flags are latched into the interrupt LABEL: RETI
control system during State 5 of every machine cycle. The samples As soon as any priority interrupt is acknowledged, the Interrupt
are polled during the following machine cycle. If the flag for an Enable (IE) register is redefined so as to disable all but priority 2
enabled interrupt is found to be set (1), the interrupt system interrupts. Then a CALL to LABEL executes the RETI instruction,
generates an LCALL to the appropriate location in Program Memory, which clears the priority 1 interrupt-in-progress flip-flop. At this point
unless some other condition blocks the interrupt. Several conditions any priority 1 interrupt that is enabled can be serviced, but only
can block an interrupt, among them that an interrupt of equal or priority 2 interrupts are enabled.
higher priority level is already in progress.
POPing IE restores the original enable byte. Then a normal RET
The hardware-generated LCALL causes the contents of the (rather than another RETI) is used to terminate the service routine.
Program Counter to be pushed into the stack, and reloads the PC The additional software adds 10µs (at 12MHz) to priority 1
with the beginning address of the service routine. As previously interrupts.
March 1995 15
A13 - 80C51 FAMILY PROGRAMMER’S GUIDE
-99-
Philips Semiconductors
PROGRAMMER’S GUIDE AND INSTRUCTION SET register bank contains eight 1-byte registers 0 through 7. Reset
initializes the stack pointer to location 07H, and it is incremented
Memory Organization once to start from location 08H, which is the first register (R0) of
the second register bank. Thus, in order to use more than one
Program Memory register bank, the SP should be initialized to a different location
The 80C51 has separate address spaces for program and data of the RAM where it is not used for data storage (i.e., the higher
memory. The Program memory can be up to 64k bytes long. The part of the RAM).
lower 4k can reside on-chip. Figure 1 shows a map of the 80C51
program memory. 2. Bit Addressable Area: 16 bytes have been assigned for this
segment, 20H-2FH. Each one of the 128 bits of this segment can
The 80C51 can address up to 64k bytes of data memory to the chip. be directly addressed (0-7FH). The bits can be referred to in two
The MOVX instruction is used to access the external data memory. ways, both of which are acceptable by most assemblers. One
The 80C51 has 128 bytes of on-chip RAM, plus a number of Special way is to refer to their address (i.e., 0-7FH). The other way is
Function Registers (SFRs). The lower 128 bytes of RAM can be with reference to bytes 20H to 2FH. Thus, bits 0-7 can also be
accessed either by direct addressing (MOV data addr) or by indirect referred to as bits 20.0-20.7, and bits 8-FH are the same as
addressing (MOV @Ri). Figure 2 shows the Data Memory 21.0-21.7, and so on. Each of the 16 bytes in this segment can
organization. also be addressed as a byte.
3. Scratch Pad Area: 30H through 7FH are available to the user as
Direct and Indirect Address Area
data RAM. However, if the stack pointer has been initialized to
The 128 bytes of RAM which can be accessed by both direct and
this area, enough bytes should be left aside to prevent SP data
indirect addressing can be divided into three segments as listed
destruction.
below and shown in Figure 3.
1. Register Banks 0-3: Locations 0 through 1FH (32 bytes). The
Figure 2 shows the different segments of the on-chip RAM.
device after reset defaults to register bank 0. To use the other
register banks, the user must select them in software. Each
FFFF FFFF
60k
BYTES
EXTERNAL
OR 64k
BYTES
EXTERNAL
1000
AND
0FFF
4k BYTES
INTERNAL
0000 0000
SU00567
1997 Sep 18 1
Philips Semiconductors
0FFF
INTERNAL
FF
64k
BYTES
SFRs EXTERNAL
DIRECT ADDRESSING
ONLY
80
AND
7F
DRIECT AND INDIRECT
ADDRESSING
00 0000
SU00568
8 BYTES
78 7F
70 77
68 6F
60 67
58 5F SCRATCH
PAD
50 57 AREA
48 4F
40 47
38 3F
30 37
28 ... 7F 2F BIT
ADDRESSABLE
20 0 ... 27 SEGMENT
18 3 1F
10 2 17 REGISTER
BANKS
08 1 0F
00 0 07
SU00569
1997 Sep 18 2
Philips Semiconductors
87 86 85 84 83 82 81 80
P0* Port 0 80H AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 FFH
97 96 95 94 93 92 91 90
P1* Port 1 90H – – – – – – T2EX T2 FFH
A7 A6 A5 A4 A3 A2 A1 A0
P2* Port 2 A0H A15 A14 A13 A12 A11 A10 A9 A8 FFH
B7 B6 B5 B4 B3 B2 B1 B0
P3* Port 3 B0H RD WR T1 T0 INT1 INT0 TxD Rxd FFH
PCON1 Power control 87H SMOD – – – GF1 GF0 PD IDL 0xxxxxxxB
D7 D6 D5 D4 D3 D2 D1 D0
PSW* Program status word D0H CY AC F0 RS1 RS0 OV – P 00H
SBUF Serial data buffer 99H xxxxxxxxB
9F 9E 9D 9C 9B 9A 99 98
SCON* Serial controller 98H SM0 SM1 SM2 REN TB8 RB8 TI RI 00H
SP Stack pointer 81H 07H
8F 8E 8D 8C 8B 8A 89 88
TCON* Timer control 88H TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
TH0 Timer high 0 8CH 00H
TH1 Timer high 1 8DH 00H
TL0 Timer low 0 8AH 00H
TL1 Timer low 1 8BH 00H
TMOD Timer mode 89H GATE C/T M1 M0 GATE C/T M1 M0 00H
NOTES:
* Bit addressable
1. Bits GF1, GF0, PD, and IDL of the PCON register are not implemented on the NMOS 8051/8031.
1997 Sep 18 3
Philips Semiconductors
8 BYTES
F8 FF
F0 B F7
E8 EF
E0 ACC E7
D8 DF
D0 PSW D7
C8 CF
C0 C7
B8 IP BF
B0 P3 B7
A8 IE AF
A0 P2 A7
98 SCON SBUF 9F
90 P1 97
BIT ADDRESSABLE
SU00570
1997 Sep 18 4
Philips Semiconductors
Those SFRs that have their bits assigned for various functions are listed in this section. A brief description of each bit is
provided for quick reference. For more detailed information refer to the Architecture Chapter of this book.
CY AC F0 RS1 RS0 OV – P
SMOD Double baud rate bit. If Timer 1 is used to generate baud rate and SMOD = 1, the baud rate is doubled when the Serial
Port is used in modes 1, 2, or 3.
– Not implemented, reserved for future use.*
– Not implemented reserved for future use.*
– Not implemented reserved for future use.*
GF1 General purpose flag bit.
GF0 General purpose flag bit.
PD Power Down Bit. Setting this bit activates Power Down operation in the 80C51. (Available only in CMOS.)
IDL Idle mode bit. Setting this bit activates Idle Mode operation in the 80C51. (Available only in CMOS.)
If 1s are written to PD and IDL at the same time, PD takes precedence.
* User software should not write 1s to reserved bits. These bits may be used in future 8051 products to invoke new features.
1997 Sep 18 5
Philips Semiconductors
INTERRUPTS:
To use any of the interrupts in the 80C51 Family, the following three steps must be taken.
1. Set the EA (enable all) bit in the IE register to 1.
2. Set the corresponding individual interrupt enable bit in the IE register to 1.
3. Begin the interrupt service routine at the corresponding Vector Address of that interrupt. See Table below.
In addition, for external interrupts, pins INT0 and INT1 (P3.2 and P3.3) must be set to 1, and depending on whether the
interrupt is to be level or transition activated, bits IT0 or IT1 in the TCON register may need to be set to 1.
ITx = 0 level activated
ITx = 1 transition activated
EA IE.7 Disables all interrupts. If EA = 0, no interrupt will be acknowledged. If EA = 1, each interrupt source is
individually enabled or disabled by setting or clearing its enable bit.
— IE.6 Not implemented, reserved for future use.*
— IE.5 Not implemented, reserved for future use.*
ES IE.4 Enable or disable the serial port interrupt.
ET1 IE.3 Enable or disable the Timer 1 overflow interrupt.
EX1 IE.2 Enable or disable External Interrupt 1.
ET0 IE.1 Enable or disable the Timer 0 overflow interrupt.
EX0 IE.0 Enable or disable External Interrupt 0.
* User software should not write 1s to reserved bits. These bits may be used in future 80C51 products to invoke new features.
1997 Sep 18 6
Philips Semiconductors
1997 Sep 18 7
Philips Semiconductors
TF1 TCON.7 Timer 1 overflow flag. Set by hardware when the Timer/Counter 1 overflows. Cleared by hardware as
processor vectors to the interrupt service routine.
TR1 TCON.6 Timer 1 run control bit. Set/cleared by software to turn Timer/Counter 1 ON/OFF.
TF0 TCON.5 Timer 0 overflow flag. Set by hardware when the Timer/Counter 0 overflows. Cleared by hardware as
processor vectors to the service routine.
TR0 TCON.4 Timer 0 run control bit. Set/cleared by software to turn Timer/Counter 0 ON/OFF.
IE1 TCON.3 External Interrupt 1 edge flag. Set by hardware when External Interrupt edge is detected. Cleared by
hardware when interrupt is processed.
IT1 TCON.2 Interrupt 1 type control bit. Set/cleared by software to specify falling edge/low level triggered External
Interrupt.
IE0 TCON.1 External Interrupt 0 edge flag. Set by hardware when External Interrupt edge detected. Cleared by
hardware when interrupt is processed.
IT0 TCON.0 Interrupt 0 type control bit. Set/cleared by software to specify falling edge/low level triggered External
Interrupt.
Timer 1 Timer 0
GATE When TRx (in TCON) is set and GATE = 1, TIMER/COUNTERx will run only while INTx pin is high (hardware control).
When GATE = 0, TIMER/COUNTERx will run only while TRx = 1 (software control).
C/T Timer or Counter selector. Cleared for Timer operation (input from internal system clock). Set for Counter operation
(input from Tx input pin).
M1 Mode selector bit. (NOTE 1)
M0 Mode selector bit. (NOTE 1)
NOTE 1:
M1 M0 Operating Mode
0 0 0 13-bit Timer (8048 compatible)
0 1 1 16-bit Timer/Counter
1 0 2 8-bit Auto-Reload Timer/Counter
1 1 3 (Timer 0) TL0 is an 8-bit Timer/Counter controlled by the standart Timer 0
control bits. TH0 is an8-bit Timer and is controlled by Timer 1 control bits.
1 1 3 (Timer 1) Timer/Counter 1 stopped.
1997 Sep 18 8
Philips Semiconductors
TIMER SET-UP
Tables 2 through 5 give some values for TMOD which can be used to set up Timer 0 in different modes.
It is assumed that only one timer is being used at a time. If it is desired to run Timers 0 and 1 simultaneously, in any mode, the
value in TMOD for Timer 0 must be ORed with the value shown for Timer 1 (Tables 5 and 6).
For example, if it is desired to run Timer 0 in mode 1 GATE (external control), and Timer 1 in mode 2 COUNTER, then the value
that must be loaded into TMOD is 69H (09H from Table 2 ORed with 60H from Table 5).
Moreover, it is assumed that the user, at this point, is not ready to turn the timers on and will do that at a different point in the
program by setting bit TRx (in TCON) to 1.
TIMER/COUNTER 0
Table 2. As a Timer:
TMOD
MODE TIMER 0 INTERNAL EXTERNAL
FUNCTION CONTROL CONTROL
(NOTE 1) (NOTE 2)
0 13-bit Timer 00H 08H
1 16-bit Timer 01H 09H
2 8-bit Auto-Reload 02H 0AH
3 Two 8-bit Timers 03H 0BH
Table 3. As a Counter:
TMOD
MODE COUNTER 0 INTERNAL EXTERNAL
FUNCTION CONTROL CONTROL
(NOTE 1) (NOTE 2)
0 13-bit Timer 04H 0CH
1 16-bit Timer 05H 0DH
2 8-bit Auto-Reload 06H 0EH
3 One 8-bit Counter 07H 0FH
NOTES:
1. The timer is turned ON/OFF by setting/clearing bit TR0 in the software.
2. The Timer is turned ON/OFF by the 1-to-0 transition on INT0 (P3.2) when TR0 = 1 (hardware control).
1997 Sep 18 9
Philips Semiconductors
TIMER/COUNTER 1
Table 4. As a Timer:
TMOD
MODE TIMER 1 INTERNAL EXTERNAL
FUNCTION CONTROL CONTROL
(NOTE 1) (NOTE 2)
0 13-bit Timer 00H 80H
1 16-bit Timer 10H 90H
2 8-bit Auto-Reload 20H A0H
3 Does not run 30H B0H
Table 5. As a Counter:
TMOD
MODE COUNTER 1 INTERNAL EXTERNAL
FUNCTION CONTROL CONTROL
(NOTE 1) (NOTE 2)
0 13-bit Timer 40H C0H
1 16-bit Timer 50H D0H
2 8-bit Auto-Reload 60H E0H
3 Not available – –
NOTES:
1. The timer is turned ON/OFF by setting/clearing bit TR1 in the software.
2. The Timer is turned ON/OFF by the 1-to-0 transition on INT1 (P3.2) when TR1 = 1 (hardware control).
1997 Sep 18 10
Philips Semiconductors
1997 Sep 18 11
Philips Semiconductors
If SMOD = 0, then K = 1.
If SMOD = 1, then K = 2 (SMOD is in the PCON register).
Most of the time the user knows the baud rate and needs to know the reload value for TH1.
K Osc Freq
TH1 + 256 *
384 baud rate
TH1 must be an integer value. Rounding off TH1 to the nearest integer may not produce the desired baud rate. In this case, the
user may have to choose another crystal frequency.
Since the PCON register is not bit addressable, one way to set the bit is logical ORing the PCON register (i.e., ORL
PCON,#80H). The address of PCON is 87H.
1997 Sep 18 12
A14 - NOTICE TECHNIQUE DU 8255
-100-
82C55A
CHMOS PROGRAMMABLE PERIPHERAL INTERFACE
Y Compatible with all Intel and Most Y Control Word Read-Back Capability
Other Microprocessors Y Direct Bit Set/Reset Capability
Y High Speed, ‘‘Zero Wait State’’ Y 2.5 mA DC Drive Capability on all I/O
Operation with 8 MHz 8086/88 and Port Outputs
80186/188
Y Available in 40-Pin DIP and 44-Pin PLCC
Y 24 Programmable I/O Pins
Y Available in EXPRESS
Y Low Power CHMOS Ð Standard Temperature Range
Y Completely TTL Compatible Ð Extended Temperature Range
The Intel 82C55A is a high-performance, CHMOS version of the industry standard 8255A general purpose
programmable I/O device which is designed for use with all Intel and most other microprocessors. It provides
24 I/O pins which may be individually programmed in 2 groups of 12 and used in 3 major modes of operation.
The 82C55A is pin compatible with the NMOS 8255A and 8255A-5.
In MODE 0, each group of 12 I/O pins may be programmed in sets of 4 and 8 to be inputs or outputs. In
MODE 1, each group may be programmed to have 8 lines of input or output. 3 of the remaining 4 pins are used
for handshaking and interrupt control signals. MODE 2 is a strobed bi-directional bus configuration.
The 82C55A is fabricated on Intel’s advanced CHMOS III technology which provides low power consumption
with performance equal to or greater than the equivalent NMOS product. The 82C55A is available in 40-pin
DIP and 44-pin plastic leaded chip carrier (PLCC) packages.
231256 – 31
231256 – 1
Figure 1. 82C55A Block Diagram
231256 – 2
Figure 2. 82C55A Pinout
Diagrams are for pin reference only. Package
sizes are not to scale.
2
82C55A
82C55A FUNCTIONAL DESCRIPTION Each of the Control blocks (Group A and Group B)
accepts ‘‘commands’’ from the Read/Write Control
Logic, receives ‘‘control words’’ from the internal
General data bus and issues the proper commands to its as-
sociated ports.
The 82C55A is a programmable peripheral interface
device designed for use in Intel microcomputer sys-
Control Group A - Port A and Port C upper (C7 – C4)
tems. Its function is that of a general purpose I/O
Control Group B - Port B and Port C lower (C3 – C0)
component to interface peripheral equipment to the
microcomputer system bus. The functional configu- The control word register can be both written and
ration of the 82C55A is programmed by the system
read as shown in the address decode table in the
software so that normally no external logic is neces-
pin descriptions. Figure 6 shows the control word
sary to interface peripheral devices or structures.
format for both Read and Write operations. When
the control word is read, bit D7 will always be a logic
Data Bus Buffer ‘‘1’’, as this implies control word mode information.
3
82C55A
231256 – 3
Figure 3. 82C55A Block Diagram Showing Data Bus Buffer and Read/Write Control Logic Functions
*NOTE: 231256 – 4
Port pins loaded with more than 20 pF capacitance may not have their logic level guaranteed following a hardware reset.
4
82C55A
Mode Selection
5
82C55A
6
82C55A
231256 – 8
231256 – 9
7
82C55A
MODE 0 Configurations
231256 – 10
8
82C55A
231256 – 11
9
82C55A
231256 – 12
10
82C55A
INTE A
Controlled by bit set/reset of PC4.
INTE B 231256 – 13
231256 – 14
11
82C55A
INTE A
Controlled by bit set/reset of PC6.
INTE B
Controlled by bit set/reset of PC2.
231256 – 15
231256 – 16
12
82C55A
Combinations of MODE 1
Port A and Port B can be individually defined as input or output in Mode 1 to support a wide variety of strobed
I/O applications.
231256 – 17
MODE 2 Basic Functional Definitions: INTE 1 (The INTE Flip-Flop Associated with
# Used in Group A only. OBF). Controlled by bit set/reset of PC6.
# One 8-bit, bi-directional bus port (Port A) and a 5-
bit control port (Port C). Input Operations
# Both inputs and outputs are latched. STB (Strobe Input). A ‘‘low’’ on this input loads
# The 5-bit control port (Port C) is used for control data into the input latch.
and status for the 8-bit, bi-directional bus port
(Port A). IBF (Input Buffer Full F/F). A ‘‘high’’ on this output
indicates that data has been loaded into the input
latch.
Bidirectional Bus I/O Control Signal Definition
INTR (Interrupt Request). A high on this output can INTE 2 (The INTE Flip-Flop Associated with IBF).
be used to interrupt the CPU for input or output oper- Controlled by bit set/reset of PC4.
ations.
13
82C55A
231256 – 18
231256 – 20
14
82C55A
231256 – 21
15
82C55A
Special Mode Combination Considerations change an interrupt enable flag, the ‘‘Set/Reset Port
C Bit’’ command must be used.
There are several combinations of modes possible.
For any combination, some or all of the Port C lines With a ‘‘Set/Reset Port C Bit’’ command, any Port C
are used for control or status. The remaining bits are line programmed as an output (including INTR, IBF
either inputs or outputs as defined by a ‘‘Set Mode’’ and OBF) can be written, or an interrupt enable flag
command. can be either set or reset. Port C lines programmed
as inputs, including ACK and STB lines, associated
During a read of Port C, the state of all the Port C with Port C are not affected by a ‘‘Set/Reset Port C
lines, except the ACK and STB lines, will be placed Bit’’ command. Writing to the corresponding Port C
on the data bus. In place of the ACK and STB line bit positions of the ACK and STB lines with the
states, flag status will appear on the data bus in the ‘‘Set/Reset Port C Bit’’ command will affect the
PC2, PC4, and PC6 bit positions as illustrated by Group A and Group B interrupt enable flags, as illus-
Figure 18. trated in Figure 18.
16
82C55A
GROUP A GROUP B
(Defined By Mode 0 or Mode 1 Selection)
17
82C55A
ABSOLUTE MAXIMUM RATINGS* NOTICE: This is a production data sheet. The specifi-
cations are subject to change without notice.
Ambient Temperature Under BiasÀÀÀÀ0§ C to a 70§ C
*WARNING: Stressing the device beyond the ‘‘Absolute
Storage Temperature ÀÀÀÀÀÀÀÀÀ b 65§ C to a 150§ C Maximum Ratings’’ may cause permanent damage.
Supply Voltage ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ b 0.5 to a 8.0V These are stress ratings only. Operation beyond the
‘‘Operating Conditions’’ is not recommended and ex-
Operating Voltage ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ a 4V to a 7V tended exposure beyond the ‘‘Operating Conditions’’
Voltage on any InputÀÀÀÀÀÀÀÀÀÀGND b 2V to a 6.5V may affect device reliability.
Voltage on any Output ÀÀGND b 0.5V to VCC a 0.5V
Power Dissipation ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ1 Watt
D.C. CHARACTERISTICS
TA e 0§ C to 70§ C, VCC e a 5V g 10%, GND e 0V (TA e b 40§ C to a 85§ C for Extended Temperture)
Symbol Parameter Min Max Units Test Conditions
VIL Input Low Voltage b 0.5 0.8 V
VIH Input High Voltage 2.0 VCC V
VOL Output Low Voltage 0.4 V IOL e 2.5 mA
VOH Output High Voltage 3.0 V IOH e b 2.5 mA
VCC b 0.4 V IOH e b 100 mA
IIL Input Leakage Current g1 mA VIN e VCC to 0V
(Note 1)
IOFL Output Float Leakage Current g 10 mA VIN e VCC to 0V
(Note 2)
IDAR Darlington Drive Current g 2.5 (Note 4) mA Ports A, B, C
Rext e 500X
Vext e 1.7V
IPHL Port Hold Low Leakage Current a 50 a 300 mA VOUT e 1.0V
Port A only
IPHH Port Hold High Leakage Current b 50 b 300 mA VOUT e 3.0V
Ports A, B, C
IPHLO Port Hold Low Overdrive Current b 350 mA VOUT e 0.8V
IPHHO Port Hold High Overdrive Current a 350 mA VOUT e 3.0V
ICC VCC Supply Current 10 mA (Note 3)
ICCSB VCC Supply Current-Standby 10 mA VCC e 5.5V
VIN e VCC or GND
Port Conditions
If I/P e Open/High
O/P e Open Only
With Data Bus e
High/Low
CS e High
Reset e Low
Pure Inputs e
Low/High
NOTES:
1. Pins A1, A0, CS, WR, RD, Reset.
2. Data Bus; Ports B, C.
3. Outputs open.
4. Limit output current to 4.0 mA.
18
82C55A
CAPACITANCE
TA e 25§ C, VCC e GND e 0V
Symbol Parameter Min Max Units Test Conditions
CIN Input Capacitance 10 pF Unmeasured plns
returned to GND
CI/O I/O Capacitance 20 pF
fc e 1 MHz(5)
NOTE:
5. Sampled not 100% tested.
A.C. CHARACTERISTICS
TA e 0§ to 70§ C, VCC e a 5V g 10%, GND e 0V
TA e b 40§ C to a 85§ C for Extended Temperature
BUS PARAMETERS
READ CYCLE
82C55A-2 Test
Symbol Parameter Units
Conditions
Min Max
tAR Address Stable Before RD v 0 ns
tRA Address Hold Time After RDu 0 ns
tRR RD Pulse Width 150 ns
tRD Data Delay from RD v 120 ns
tDF RD u to Data Floating 10 75 ns
tRV Recovery Time between RD/WR 200 ns
WRITE CYCLE
82C55A-2 Test
Symbol Parameter Units
Conditions
Min Max
tAW Address Stable Before WR v 0 ns
tWA Address Hold Time After WR u 20 ns Ports A & B
20 ns Port C
tWW WR Pulse Width 100 ns
tDW Data Setup Time Before WR u 100 ns
tWD Data Hold Time After WR u 30 ns Ports A & B
30 ns Port C
19
82C55A
OTHER TIMINGS
82C55A-2 Units
Symbol Parameter Test
Conditions
Min Max
tWB WR e 1 to Output 350 ns
tlR Peripheral Data Before RD 0 ns
tHR Peripheral Data After RD 0 ns
tAK ACK Pulse Width 200 ns
tST STB Pulse Width 100 ns
tPS Per. Data Before STB High 20 ns
tPH Per. Data After STB High 50 ns
tAD ACK e 0 to Output 175 ns
tKD ACK e 1 to Output Float 20 250 ns
tWOB WR e 1 to OBF e 0 150 ns
tAOB ACK e 0 to OBF e 1 150 ns
tSIB STB e 0 to IBF e 1 150 ns
tRIB RD e 1 to IBF e 0 150 ns
tRIT RD e 0 to INTR e 0 200 ns
tSIT STB e 1 to INTR e 1 150 ns
tAIT ACK e 1 to INTR e 1 150 ns
tWIT WR e 0 to INTR e 0 200 ns see note 1
tRES Reset Pulse Width 500 ns see note 2
NOTE:
1. INTRu may occur as early as WRv.
2. Pulse width of initial Reset pulse after power on must be at least 50 mSec. Subsequent Reset pulses may be 500 ns
minimum. The output Ports A, B, or C may glitch low during the reset pulse but all port pins will be held at a logic ‘‘one’’ level
after the reset pulse.
20
82C55A
WAVEFORMS
231256 – 22
231256 – 23
21
82C55A
WAVEFORMS (Continued)
231256 – 24
231256 – 25
22
82C55A
WAVEFORMS (Continued)
MODE 2 (BIDIRECTIONAL)
231256 – 26
Note:
Any sequence where WR occurs before ACK AND STB occurs before RD is permissible.
(INTR e IBF # MASK # STB # RD a OBF # MASK # ACK # WR)
231256 – 28
231256 – 27
231256 – 29
231256 – 30
A.C. Testing Inputs Are Driven At 2.4V For A Logic 1 And 0.45V
For A Logic 0 Timing Measurements Are Made At 2.0V For A *VEXT Is Set At Various Voltages During Testing To Guarantee
Logic 1 And 0.8 For A Logic 0. The Specification. CL Includes Jig Capacitance.
23