Compare commits

...

2 commits

Author SHA1 Message Date
Geoffrey Frogeye 902ec65f1a Début CR TP3 2017-05-19 07:11:08 +02:00
Geoffrey Frogeye c7695e6e75 Petites modifs TP1 / TP2 avant rendu 2017-05-19 06:36:18 +02:00
13 changed files with 271 additions and 558 deletions

View file

@ -1,5 +1,5 @@
# Compte-rendu TP1
## DJERABA Taky PREUD'HOMME Geoffrey
# Compte-rendu TP1 Microprocesseurs
## DJERABA Taky PREUD'HOMME Geoffrey (IMA3 TP2)
Ce TP est une introduction à la programmation de l'ATMEGA 2560 et à la simulation du microcontrôleur tout en rappelant les bases de la programmation en assembleur AVR8.

View file

@ -1,5 +1,5 @@
# Compte-rendu TP1
## DJERABA Taky PREUD'HOMME Geoffrey
# Compte-rendu TP2 Microprocesseurs
## DJERABA Taky PREUD'HOMME Geoffrey (IMA3 TP2)
Ce TP a pour but de nous familiariser avec la gestion des interruptions et du watchdog sur l'Atmega 2560.

View file

@ -1,4 +1,4 @@
.equ PINA = 0x00
.equ PINA = 0x00
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PINC = 0x06
@ -49,8 +49,8 @@ debut:
LDI R16,0
STS d0,R16
; select <- 0x01
LDI R16,0x01
; select <- 0b00100000
LDI R16,0b00100000
STS select,R16
@ -179,10 +179,10 @@ tm:
LDS R16,select
OUT PortC,R16
; si select = 0x80 alors PortA@IO <- afficheur@ROM[d0]
; si select = 0b10000000 alors PortA@IO <- afficheur@ROM[d2]
LDS R16,select
PUSH R16
LDI R16,0x80
LDI R16,0b10000000
POP R17
CP R17,R16
BREQ eti9
@ -193,7 +193,7 @@ eti9:
eti10:
TST R16
BREQ eti11
LDS R16,d0
LDS R16,d2
LDI R30,low(afficheur<<1)
LDI R31,high(afficheur<<1)
CLR R17
@ -203,10 +203,10 @@ eti10:
OUT PortA,R16
eti11:
; si select = 0x40 alors PortA@IO <- afficheur@ROM[d1]
; si select = 0b01000000 alors PortA@IO <- afficheur@ROM[d1]
LDS R16,select
PUSH R16
LDI R16,0x40
LDI R16,0b01000000
POP R17
CP R17,R16
BREQ eti12
@ -227,10 +227,10 @@ eti13:
OUT PortA,R16
eti14:
; si select = 0x20 alors PortA@IO <- afficheur@ROM[d2]
; si select = 0b00100000 alors PortA@IO <- afficheur@ROM[d0]
LDS R16,select
PUSH R16
LDI R16,0x20
LDI R16,0b00100000
POP R17
CP R17,R16
BREQ eti15
@ -241,7 +241,7 @@ eti15:
eti16:
TST R16
BREQ eti17
LDS R16,d2
LDS R16,d0
LDI R30,low(afficheur<<1)
LDI R31,high(afficheur<<1)
CLR R17
@ -252,7 +252,7 @@ eti16:
eti17:
lsl select
; si select = 0 alors select <- 0x20
; si select = 0 alors select <- 0b00100000
LDS R16,select
PUSH R16
LDI R16,0
@ -266,7 +266,7 @@ eti18:
eti19:
TST R16
BREQ eti20
LDI R16,0x20
LDI R16,0b00100000
STS select,R16
eti20:

View file

@ -1,4 +1,4 @@
.equ PINA = 0x00
.equ PINA = 0x00
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PINC = 0x06
@ -40,7 +40,7 @@ debut:
d2 <- 0
d1 <- 0
d0 <- 0
select <- 0x01
select <- 0b00100000
cli
; Configuration des ports
@ -81,9 +81,9 @@ affichage:
tm:
PortC@IO <- select
si select = 0x80 alors PortA@IO <- afficheur@ROM[d0]
si select = 0x40 alors PortA@IO <- afficheur@ROM[d1]
si select = 0x20 alors PortA@IO <- afficheur@ROM[d2]
si select = 0b10000000 alors PortA@IO <- afficheur@ROM[d2]
si select = 0b01000000 alors PortA@IO <- afficheur@ROM[d1]
si select = 0b00100000 alors PortA@IO <- afficheur@ROM[d0]
lsl select
si select = 0 alors select <- 0x20
si select = 0 alors select <- 0b00100000
reti

View file

@ -1,274 +0,0 @@
.equ PINA = 0x00
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PINC = 0x06
.equ DDRC = 0x07
.equ PORTC = 0x08
.equ WDTCSR = 0x60
.equ TCCR0A = 0x24
.equ TCCR0B = 0x25
.equ TIMSK0 = 0x6E
.equ TIFR0 = 0x35
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPL = 0x3D
.def d2 = r19
.def d1 = r20
.def d0 = r21
.def select = r22
.org 0x000
; Vecteur RESET
jmp debut
.org 0x0018 ; Interruption du watchdog
jmp wd
.org 0x002E ; Interruption du timer
jmp tm
.org 0x0080
afficheur:
.DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF
; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
debut:
; d2 <- 0
LDI R16,0
STS d2,R16
; d1 <- 0
LDI R16,0
STS d1,R16
; d0 <- 0
LDI R16,0
STS d0,R16
; select <- 0b00100000
LDI R16,0b00100000
STS select,R16
cli
; Configuration des ports
; DDRA@IO <- 0xFF
LDI R16,0xFF
OUT DDRA,R16
; DDRC@IO <- 0xFF
LDI R16,0xFF
OUT DDRC,R16
; Watchdog toutes les secondes
; WDTCSR <- 0x10
LDI R16,0x10
STS WDTCSR,R16
; WDTCSR <- 0b01000110
LDI R16,0b01000110
STS WDTCSR,R16
; Timer toutes les 2 ms
; TCCR0A@IO <- 0x00
LDI R16,0x00
OUT TCCR0A,R16
; TCCR0B@IO <- 0x04
LDI R16,0x04
OUT TCCR0B,R16
; TIMSK0 <- 0x01
LDI R16,0x01
STS TIMSK0,R16
; TIFR0 <- 0x01
LDI R16,0x01
STS TIFR0,R16
sei
boucle:
sleep
; jump boucle
JMP boucle
wd:
inc d0
; si d0 < 10 saut affichage
LDS R16,d0
PUSH R16
LDI R16,10
POP R17
CP R17,R16
BRLO eti0
CLR R16
RJMP eti1
eti0:
LDI R16,0x01
eti1:
TST R16
BREQ eti2
JMP affichage
eti2:
; d0 <- 0
LDI R16,0
STS d0,R16
inc d1
; si d1 < 10 saut affichage
LDS R16,d1
PUSH R16
LDI R16,10
POP R17
CP R17,R16
BRLO eti3
CLR R16
RJMP eti4
eti3:
LDI R16,0x01
eti4:
TST R16
BREQ eti5
JMP affichage
eti5:
; d1 <- 0
LDI R16,0
STS d1,R16
inc d2
; si d2 < 10 saut affichage
LDS R16,d2
PUSH R16
LDI R16,10
POP R17
CP R17,R16
BRLO eti6
CLR R16
RJMP eti7
eti6:
LDI R16,0x01
eti7:
TST R16
BREQ eti8
JMP affichage
eti8:
; d2 <- 0
LDI R16,0
STS d2,R16
affichage:
; Affichage Simulateur
; PORTC@IO <- afficheur@ROM[d0]
; PORTB@IO <- afficheur@ROM[d1]
; PORTA@IO <- afficheur@ROM[d2]
reti
tm:
; PortC@IO <- select
LDS R16,select
OUT PortC,R16
; si select = 0b10000000 alors PortA@IO <- afficheur@ROM[d2]
LDS R16,select
PUSH R16
LDI R16,0b10000000
POP R17
CP R17,R16
BREQ eti9
CLR R16
RJMP eti10
eti9:
LDI R16,0x01
eti10:
TST R16
BREQ eti11
LDS R16,d2
LDI R30,low(afficheur<<1)
LDI R31,high(afficheur<<1)
CLR R17
ADD R30,R16
ADC R31,R17
LPM R16,Z
OUT PortA,R16
eti11:
; si select = 0b01000000 alors PortA@IO <- afficheur@ROM[d1]
LDS R16,select
PUSH R16
LDI R16,0b01000000
POP R17
CP R17,R16
BREQ eti12
CLR R16
RJMP eti13
eti12:
LDI R16,0x01
eti13:
TST R16
BREQ eti14
LDS R16,d1
LDI R30,low(afficheur<<1)
LDI R31,high(afficheur<<1)
CLR R17
ADD R30,R16
ADC R31,R17
LPM R16,Z
OUT PortA,R16
eti14:
; si select = 0b00100000 alors PortA@IO <- afficheur@ROM[d0]
LDS R16,select
PUSH R16
LDI R16,0b00100000
POP R17
CP R17,R16
BREQ eti15
CLR R16
RJMP eti16
eti15:
LDI R16,0x01
eti16:
TST R16
BREQ eti17
LDS R16,d0
LDI R30,low(afficheur<<1)
LDI R31,high(afficheur<<1)
CLR R17
ADD R30,R16
ADC R31,R17
LPM R16,Z
OUT PortA,R16
eti17:
lsl select
; si select = 0 alors select <- 0b00100000
LDS R16,select
PUSH R16
LDI R16,0
POP R17
CP R17,R16
BREQ eti18
CLR R16
RJMP eti19
eti18:
LDI R16,0x01
eti19:
TST R16
BREQ eti20
LDI R16,0b00100000
STS select,R16
eti20:
reti

View file

@ -1,89 +0,0 @@
.equ PINA = 0x00
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PINC = 0x06
.equ DDRC = 0x07
.equ PORTC = 0x08
.equ WDTCSR = 0x60
.equ TCCR0A = 0x24
.equ TCCR0B = 0x25
.equ TIMSK0 = 0x6E
.equ TIFR0 = 0x35
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPL = 0x3D
.def d2 = r19
.def d1 = r20
.def d0 = r21
.def select = r22
.org 0x000
; Vecteur RESET
jmp debut
.org 0x0018 ; Interruption du watchdog
jmp wd
.org 0x002E ; Interruption du timer
jmp tm
.org 0x0080
afficheur:
.DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF
; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
debut:
d2 <- 0
d1 <- 0
d0 <- 0
select <- 0b00100000
cli
; Configuration des ports
DDRA@IO <- 0xFF
DDRC@IO <- 0xFF
; Watchdog toutes les secondes
WDTCSR <- 0x10
WDTCSR <- 0b01000110
; Timer toutes les 2 ms
TCCR0A@IO <- 0x00
TCCR0B@IO <- 0x04
TIMSK0 <- 0x01
TIFR0 <- 0x01
sei
boucle:
sleep
jump boucle
wd:
inc d0
si d0 < 10 saut affichage
d0 <- 0
inc d1
si d1 < 10 saut affichage
d1 <- 0
inc d2
si d2 < 10 saut affichage
d2 <- 0
affichage:
; Affichage Simulateur
; PORTC@IO <- afficheur@ROM[d0]
; PORTB@IO <- afficheur@ROM[d1]
; PORTA@IO <- afficheur@ROM[d2]
reti
tm:
PortC@IO <- select
si select = 0b10000000 alors PortA@IO <- afficheur@ROM[d2]
si select = 0b01000000 alors PortA@IO <- afficheur@ROM[d1]
si select = 0b00100000 alors PortA@IO <- afficheur@ROM[d0]
lsl select
si select = 0 alors select <- 0b00100000
reti

125
TP2/a
View file

@ -1,125 +0,0 @@
.equ PINA = 0x00 ; définition des adresses des ports
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PIND = 0x09
.equ DDRD = 0x0A
.equ PORTD = 0x0B
.equ WDTCSR = 0x60
.equ EIMSK = 0x3D
.equ EICRA = 0x69
.equ EICRB = 0x6A
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPL = 0x3D
.def d1 = r20
.def d0 = r21
.def route = r22
.org 0x000
; Vecteur RESET
jmp debut
.org 0x0002
jmp b10s
.org 0x0004
jmp b1s
.org 0x0006
jmp marche
.org 0x0008
jmp arret
.org 0x0018
jmp wd
.org 0x0080
afficheur:
.DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF
; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
debut:
d1 <- 0 ; Digit dizaines
d0 <- 0 ; Digit unités
route <- 0 ; 1 : Four en marche, 0 : Four à l'arrêt
cli
; Configuration des ports
DDRA@IO <- 0xFF
DDRB@IO <- 0xFF
DDRD@IO <- 0x80
; Interruptions
EIMSK <- 0b00001111 ; On active les interruptions PD[3:0] sur front descendant
EICRA <- 0b10101010
EICRB <- 0b00000000
; Watchdog toutes les secondes
WDTCSR <- 0x10
WDTCSR <- 0b01000110
sei
call affiche
boucle:
sleep ; Le programme ne fonctionne que sur interruption
jump boucle
b1s: ; Bouton +1 seconde
inc d0 ; Incrémente le chiffre des unités
si d0 < 10 saut finb1s ; Si il reste inférieur à 10, on affiche juste
d0 <- 0 ; Sinon, on le remet à 0 et on fait comme si on avait appuyé sur le bouton +10 secondes
jump b10s
finb1s:
call affiche
reti
b10s: ; Bouton +10 secondes
inc d1 ; On incrémente le chiffre des dizaines
si d1 < 10 saut finb10s ; Si il reste inférieur à 10, on affiche juste
d0 <- 9 ; Sinon, on bloque à 99
d1 <- 9
finb10s:
call affiche
reti
affiche:
PORTA@IO <- afficheur@ROM[d1]
PORTB@IO <- afficheur@ROM[d0]
ret
marche: ; Bouton marche
route <- 1 ; Met la minuterie en route
PORTD@IO <- 0x80
reti
arret: ; Bouton annuler
route <- 0 ; Remet tout dans sa position d'origine
d0 <- 0
d1 <- 0
call affiche
reti
wd:
si route = 0 saut finwd ; Si on est pas en route, ne rien faire
dec d0 ; Si on est en route, décrémenter le compteur
si d0 < 10 saut prefinwd ; Si le chiffre des unités était strictement supérieur à 0, juste actualiser l'affichage
d0 <- 9 ; Si le chiffre des unités était à 0, il passe à 9 et on décrémente celui des dizaines
dec d1
si d1 < 10 saut prefinwd ; Si le chiffre des dizaines était strictement supérieur à 0, juste actualiser l'affichage
route <- 0 ; Sinon, c'est qu'on était à 00, donc il faut éteindre le four
PORTD@IO <- 0x00
d0 <- 0 ; On remet à 00 (avant ces lignes d0 = 9 et d1 = 255)
d1 <- 0
prefinwd:
call affiche
finwd:
reti

20
TP3/Makefile Normal file
View file

@ -0,0 +1,20 @@
.PHONY: default cleantmp clean
default: $(subst md,pdf,$(wildcard *.md))
SOURCES=$(wildcard *.asm) $(wildcard *.txt)
%.pdf: %.html
html2pdf -i "$<" -o "$@" -t "$* - REVIRON Athur PREUD'HOMME Geoffrey"
%.html: %.tmp ../template.html
md2html -i "$<" -o "$@" -t ../template.html
%.tmp: %.md $(SOURCES)
markedpp "$<" > "$@"
cleantmp:
rm -rf $(subst md,html,$(wildcard *.md)) *.tmp
clean: cleantmp
rm -rf $(subst md,pdf,$(wildcard *.md))

35
TP3/TP3.md Normal file
View file

@ -0,0 +1,35 @@
# Compte-rendu TP3 Microprocesseurs
## REVIRON Arthur PREUD'HOMME Geoffrey (IMA3 TP2)
Avec ce TP nous allons pouvoir nous familiariser avec le convertisseur analogique-numérique (ou ADC).
# Prise en main de l'interface ADC (TP30)
Les deux programmes permettent d'afficher en continu les valeurs entrées sur ADC0 sur l'afficheur 7-segments situé PortA. Les conversions sont déclenchées à la suite (free running mode). Le premier programme utilise cependant une scrutation et ne se préoccupe pas de savoir si la conversion est terminée. Le deuxième programme déclenche une interruption pour chaque conversion terminée, et l'afficheur n'est mis à jour qu'à ce moment là, ce qui évite de gaspiller des ressources inutilement et évite aussi de récupérer des valeurs fausses dûes à une conversion pas totalement terminée (ce qui dans ce cas ne change quelque chose que pour la première scrutation).
!include(TP30b.txt lang=avrasmplus)
# Capteur de température (TP31)
Il est ici question d'utiliser un convertisseur analogique-numérique pour récupérer les valeurs d'une sonde de température pour l'afficheur dans un résultat plus lisible.
On réutilisera la même configuration que pour le deuxième programme du TP30, cependant l'affichage va varier un peu. En effet, on veut transformer la valeur reçue de l'ADC sur [0, 255] en valeur sur [0, 32]. Pour cela, on divise d'abord la valeur par $\frac{255}{32}\approx 8$. Puis on affiche les dizaines sur le premier afficheur et les unités sur le deuxième.
!include(TP31.txt lang=avrasmplus)
# Capteur de distance (TP32)
Il est demandé d'afficher la tension fournie par le capteur infrarouge situé sur la maquette. Ne connaissant pas au préalable l'équivalence entre la tension fournie et la distance en cm, on affichera la valeur de la tension sur le plus grand intervalle possible qui est de [0, 255]. On aurait en réalité pu utiliser les 10 bits de précision que nous fournit l'ADC, mais en voyant qu'avec 8 on on obtient beaucoup de bruit nous n'avons pas jugé cela nécessaire.
On réutilise donc le code du TP22 nous permettant d'afficher un nombre différent sur les 3 afficheurs 7-segments disponible sur la carte. Pour rappel, cet afficheur utilise 4 registres, nommé `d2`, `d1`, `d0` et `select`. Les trois premiers correspondent au chiffre à afficher pour chacun des 3 afficheurs. `select` contient quant à lui l'état du port C nécessaire pour afficher un des trois digits. On configure le timer pour qu'il effectue une interruption toutes les 2 ms, dans laquelle il décale `select` afin de sélectionner un autre afficheur et envoie la représentation du digit correspondant sur le port A.
!include(TP32.txt lang=avrasmplus)
![Visualisation du capteur de distance](capteur_distance.svg)
Le capteur semble décroitre exponentiellement au fur et à mesure qu'on éloigne un obstacle de devant lui. Cependant, on remarque que si l'obstacle se rapproche trop, le capteur considère qu'il s'éloigne. Il a donc un intervalle de fonctionnement assez faible.
# Régulateur pour chauffage central (TP33)
Nous allons réaliser une application concrète de l'utilisation de l'ADC en construisant un régulateur pour chauffage central. La difficulté sera ici de lire deux entrées d'ADC en alternance : il n'est donc pas possible d'utiliser le free-running mode que nous avons utilisé jusqu'ici. Le micro-contrôleur nous propose nativement de pouvoir comparer électriquement deux entrées d'ADC pour n'avoir à traiter qu'un seul résultat, cependant nous ne pourrons pas l'utiliser dans ce cas là car les deux entrées analogiques ne sont pas sur la même échelle (la première est sur [10, 26]°C, la deuxième est sur [0, 32]°C).

View file

@ -3,45 +3,39 @@
.equ PORTA = 0x02
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPH = 0x3E
.equ SPL = 0x3D
.equ SREG = 0x3F
.equ ADMUX = 0x7C
.equ ADCSRB = 0x7B
.equ ADCSRA = 0x7A
.equ ADCH = 0x79
.equ ADCL = 0x78
.org 0x000
; Vecteur RESET
.org 0x000 ; Vecteur RESET
jmp debut
.org 0x003A
.org 0x003A ; Interruption conversion ADC terminée
jmp irqadc
.org 0x0080
codeAff:
.db 0b1111110, 0b001100
.db 0b0110111, 0b0011111
.db 0b1001101, 0b1011011
.db 0b1111011, 0b0001110
.db 0b1111111, 0b1011111
codeAff: ; Représentation des chiffres sur l'afficheur 7-segments
.db 0b1111110, 0b001100, 0b0110111, 0b0011111, 0b1001101, 0b1011011, 0b1111011, 0b0001110, 0b1111111, 0b1011111
debut:
; Intialisation de la pile
ldi r28, low(RAMEND)
ldi r29, high(RAMEND)
out SPL, r28
out SPH, r29
DDRA@IO <- 0xFF
ADMUX <- 0b01100000
ADCSRB <- 0b00000000
ADCSRA <- 0b11101111
DDRA@IO <- 0xFF ; Port A (afficheur 7-segments) en sortie
ADMUX <- 0b01100000 ; Sélection de l'ADC0
ADCSRB <- 0b00000000 ; Free running mode
ADCSRA <- 0b11101111 ; Activation des interruptions
sei
@ -49,11 +43,10 @@ boucle:
sleep
jmp boucle
irqadc:
PORTA@IO <- codeAff@ROM[ADCH/27]
irqadc: ; Dès qu'une lecture est terminée, l'afficher sur l'afficheur
PORTA@IO <- codeAff@ROM[ADCH/51] ; On passe d'une valeur sur [0, 255] à [0, 5]
reti

View file

@ -6,12 +6,12 @@
.equ PORTB = 0x05
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPH = 0x3E
.equ SPL = 0x3D
.equ SREG = 0x3F
.equ ADMUX = 0x7C
.equ ADCSRB = 0x7B
.equ ADCSRA = 0x7A
.equ ADCH = 0x79
@ -28,13 +28,8 @@
.org 0x0080
codeAff:
.db 0b1111110, 0b001100
.db 0b0110111, 0b0011111
.db 0b1001101, 0b1011011
.db 0b1111011, 0b0001110
.db 0b1111111, 0b1011111
codeAff: ; Représentation des chiffres sur l'afficheur 7-segments
.db 0b1111110, 0b001100, 0b0110111, 0b0011111, 0b1001101, 0b1011011, 0b1111011, 0b0001110, 0b1111111, 0b1011111
debut:
ldi r28, low(RAMEND)
@ -43,11 +38,11 @@ debut:
out SPL, r28
out SPH, r29
DDRA@IO <- 0xFF
DDRB@IO <- 0xFF
ADMUX <- 0b01100000
ADCSRB <- 0b00000000
ADCSRA <- 0b11101111
DDRA@IO <- 0xFF ; Port A (afficheur 7-segments) en sortie
DDRB@IO <- 0xFF ; Port B (afficheur 7-segments) en sortie
ADMUX <- 0b01100000 ; Sélection de l'ADC0
ADCSRB <- 0b00000000 ; Free running mode
ADCSRA <- 0b11101111 ; Activation des interruptions
sei
@ -58,7 +53,7 @@ boucle:
irqadc:
temp <- ADCH / 8
PORTA@IO <- codeAff@ROM[temp/10]
PORTB@IO <- codeAff@ROM[temp-(temp/10)*10]
PORTB@IO <- codeAff@ROM[temp-(temp/10)*10] ; temp%10
reti

View file

@ -6,8 +6,9 @@
.equ PORTC = 0x08
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPH = 0x3E
.equ SPL = 0x3D
.equ SREG = 0x3F
.equ TCCR0A = 0x24
@ -34,22 +35,18 @@
.org 0x002E ; Interruption du timer
jmp tm
.org 0x003A
.org 0x003A ; Interruption de l'ADC
jmp irqadc
.org 0x0080
codeAff:
.db 0b1111110, 0b001100
.db 0b0110111, 0b0011111
.db 0b1001101, 0b1011011
.db 0b1111011, 0b0001110
.db 0b1111111, 0b1011111
codeAff: ; Représentation des chiffres sur l'afficheur 7-segments
.db 0b1111110, 0b001100, 0b0110111, 0b0011111, 0b1001101, 0b1011011, 0b1111011, 0b0001110, 0b1111111, 0b1011111
debut:
; Initialisation de la pile
ldi r28, low(RAMEND)
ldi r29, high(RAMEND)
out SPL, r28
out SPH, r29
@ -57,9 +54,9 @@ debut:
DDRA@IO <- 0xFF
DDRC@IO <- 0xFF
ADMUX <- 0b01100001
ADCSRB <- 0b00000000
ADCSRA <- 0b11101111
ADMUX <- 0b01100001 ; Sélection de l'ADC1
ADCSRB <- 0b00000000 ; Free-running mode
ADCSRA <- 0b11101111 ; Activation des interruptions
; Timer toutes les 2 ms
TCCR0A@IO <- 0x00

161
TP3/capteur_distance.svg Normal file
View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="150.78093mm"
height="84.340805mm"
viewBox="0 0 150.78093 84.340805"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r"
sodipodi:docname="capteur_distance.svg">
<defs
id="defs2">
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lend"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4490"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(-0.8,0,0,-0.8,-10,0)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lstart"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4487"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.8,0,0,0.8,10,0)"
inkscape:connector-curvature="0" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="269.36956"
inkscape:cy="187.87975"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-left="5"
fit-margin-top="5"
fit-margin-right="5"
fit-margin-bottom="5"
inkscape:window-width="1600"
inkscape:window-height="882"
inkscape:window-x="0"
inkscape:window-y="1042"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(1.7479171,-50.830598)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart);marker-end:url(#Arrow1Lend)"
d="M 143.25646,122.20573 H 18.174328 V 56.607143"
id="path4485"
inkscape:connector-curvature="0" />
<flowRoot
xml:space="preserve"
id="flowRoot4801"
style="font-style:normal;font-weight:normal;font-size:15px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
transform="matrix(0.26458333,0,0,0.26458333,21.258142,1.1339286)"><flowRegion
id="flowRegion4803"><rect
id="rect4805"
width="67.857132"
height="22.857159"
x="190"
y="471.09113" /></flowRegion><flowPara
id="flowPara4807">Distance</flowPara></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot4801-9"
style="font-style:normal;font-weight:normal;font-size:15px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.51181102;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
transform="matrix(0,-0.26458333,0.26458333,0,-122.71387,162.50969)"><flowRegion
id="flowRegion4803-0"
style="stroke-width:1.51181102;stroke-miterlimit:4;stroke-dasharray:none"><rect
id="rect4805-8"
width="172.85712"
height="23.571432"
x="190"
y="471.09113"
style="stroke-width:1.51181102;stroke-miterlimit:4;stroke-dasharray:none" /></flowRegion><flowPara
id="flowPara4807-1">Tension du capteur (V)</flowPara></flowRoot> <path
style="fill:none;fill-rule:evenodd;stroke:#c52b00;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 18.142857,92.892855 c 0,0 11.116479,-3.123508 20.599702,-12.851191 34.454851,-35.34303 -25.89137,39.309516 100.541661,41.766376"
id="path4845"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<flowRoot
xml:space="preserve"
id="flowRoot4919"
style="font-style:normal;font-weight:normal;font-size:15px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
transform="matrix(0.26458333,0,0,0.26458333,5.8511007,-0.68913503)"><flowRegion
id="flowRegion4921"><rect
id="rect4923"
width="44.285713"
height="26.428572"
x="13.571428"
y="341.09113" /></flowRegion><flowPara
id="flowPara4925">1,4</flowPara></flowRoot> <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 0.26499999;stroke-dashoffset:0;stroke-opacity:1"
d="M 18.142857,92.892855 140.04923,92.872898"
id="path5071"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26458332, 0.26458332;stroke-dashoffset:0;stroke-opacity:1"
d="M 140.04923,70.555892 H 18.174328"
id="path5073"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<flowRoot
xml:space="preserve"
id="flowRoot4919-3"
style="font-style:normal;font-weight:normal;font-size:15px;line-height:25px;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
transform="matrix(0.26458333,0,0,0.26458333,6.14065,-22.813536)"><flowRegion
id="flowRegion4921-1"><rect
id="rect4923-1"
width="44.285713"
height="26.428572"
x="13.571428"
y="341.09113" /></flowRegion><flowPara
id="flowPara4925-0">3,0</flowPara></flowRoot> </g>
</svg>

After

Width:  |  Height:  |  Size: 7 KiB