Petites modifs TP1 / TP2 avant rendu

master
Geoffrey Frogeye 2017-05-19 06:36:18 +02:00
vanhempi 2d6f3613b2
commit c7695e6e75
7 muutettua tiedostoa jossa 23 lisäystä ja 511 poistoa

Näytä tiedosto

@ -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.

Näytä tiedosto

@ -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.

Näytä tiedosto

@ -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:

Näytä tiedosto

@ -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

Näytä tiedosto

@ -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

Näytä tiedosto

@ -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
Näytä tiedosto

@ -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