This repository has been archived on 2019-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
s6-up-tp/TP2/TP2.md
Geoffrey Frogeye e98ecc5c1f Trois-quarts prépa TP2
(un jour on en fera une complète avant le TP)
2017-05-03 09:47:08 +02:00

2.2 KiB

% Compte-rendu TP2 % DJERABA Taky PREUD'HOMME Geoffrey % 03/05/2017

TP2

Ce TP a pour but de nous familiariser avec la gestion des interruptions et du watchdog sur l'Atmega 2560.

Un bouton/une LED et un chien de garde (TP20)

!include(TP20.txt lang=asmplus)

Ce programme allume la LED lors de l'appui sur un bouton, et ce jusqu'à une seconde après l'avoir relâché. Si on rappuie sur le bouton pendant l'intervalle des 1s, le compteur est remis à zéro.

Chenillard par interruption (TP21)

chen ← 0b00000001
port ← 0x00 ; pair : port A, impair : port B
boucle: jump boucle ; On attend là si rien ne se passe

horaire:
Si (port & 0x01) == 0 alors DecalerGauche chen
Si (port & 0x01) == 1 alors DecalerDroite chen
Si chen != 0 saut boucle
Si (port & 0x01) == 0 alors chen ← 0b00000001
Si (port & 0x01) == 1 alors chen ← 0b10000000
Incrementer port ; On change de port
call afficher
Retourner

antihoraire:
Si (port & 0x01) == 0 alors DecalerDroite chen
Si (port & 0x01) == 1 alors DecalerGauche chen
Si chen != 0 saut boucle
Si (port & 0x01) == 0 alors chen ← 0b10000000
Si (port & 0x01) == 1 alors chen ← 0b00000001
Incrementer port ; On change de port
call afficher
Retourner

afficher:
Si (port & 0x01) == 0 alors PortB@IO ← 0x00
Si (port & 0x01) == 1 alors PortA@IO ← 0x00
Si (port & 0x01) == 0 alors PortA@IO ← chen
Si (port & 0x01) == 1 alors PortB@IO ← chen
Retourner

Compteur (TP22)

d0 ← 0

Configurer Watchdog: Interruption toutes les secondes sur wd

boucle: jump boucle

wd:
Incrementer d0
Si d0 > 10 jump d0 ← 0:

d2 ← 0
d1 ← 0
d0 ← 0
select ← 0x01
io ← 0x00

Configurer Watchdog: Interruption toutes les secondes sur wd
Configurer timer0: Interruption toutes les 8-16 ms sur tm

boucle: jump boucle

wd: 
Incrementer d0
Si d0 < 10 Retourner
d0 ← 0
Incrementer d1
Si d1 < 10 Retourner
d1 ← 0
Incrementer d2
Si d2 < 10 Retourner
d2 ← 0
Retourner ; Comportement si >999 : on revient à 000

tm:
PortC@IO ← select
Si select = 0x01 alors io ← afficheur@ROM[d0]
Si select = 0x02 alors io ← afficheur@ROM[d1]
Si select = 0x03 alors io ← afficheur@ROM[d2]
DecalerGauche io
Si io > 0x04 alors io ← 0x01
Retourner

Minuteur d'un four (TP23)