Commit 9e20955cbf237adc5e720ae61dd430f2eb454634

Authored by Geoffrey PREUD'HOMME
1 parent 968302e7

Watchdog artificiel

Showing 1 changed file with 64 additions and 32 deletions   Show diff stats
principal.txt
... ... @@ -6,6 +6,9 @@
6 6 .equ PINC = 0x06
7 7 .equ DDRC = 0x07
8 8 .equ PORTC = 0x08
  9 +.equ PING = 0x12
  10 +.equ DDRG = 0x13
  11 +.equ PORTG = 0x14
9 12  
10 13 .equ WDTCSR = 0x60
11 14  
... ... @@ -38,7 +41,7 @@
38 41 .def t2 = r8 ; Jour (3 premiers bits) et Heure (5 derniers bits)
39 42 .def t1 = r9 ; Minutes
40 43 .def t0 = r10 ; Secondes / 2
41   -.def selaff = r11 ; Digit en cours d'affichage
  44 +.def tt = r11 ; Watchdog artificiel
42 45  
43 46 ; Nommage des adresses RAM utilisées
44 47  
... ... @@ -88,15 +91,16 @@ debut:
88 91 ; Ports parallèles
89 92 DDRA@IO <- 0xFF
90 93 DDRC@IO <- 0xFF
  94 + DDRG@IO <- 0xFF
91 95  
92 96 ; Watchdog
93   - WDTCSR <- 0b00010000
94   - WDTCSR <- 0b01000111
  97 + ;WDTCSR <- 0b00010000
  98 + ;WDTCSR <- 0b01000111
95 99  
96 100 ; Timer
97   - TTCR0A@IO <- 0b00000001
98   - TTCR0B@IO <- 0b00000011
99   - TMSK0 <- 0b00000001
  101 + TTCR0A@IO <- 0b00000000
  102 + TTCR0B@IO <- 0b00000100 ; Timer toutes les 4ms
  103 + TMSK0 <- 0b00000001
100 104  
101 105 ; Interruptions externes
102 106 EIMSK <- 0b00001111
... ... @@ -109,14 +113,15 @@ debut:
109 113 ADCSRA <- 0b10011101 ; TODO Auto-trigger ?
110 114  
111 115 sei
  116 + wdr
112 117  
113 118 ; Initialisation des valeurs
114 119 ; Mercredi 12h34'56
115 120 t2 <- 0b01001100
116 121 t1 <- 34
117 122 t0 <- 28
  123 + tt <- 0
118 124  
119   - selaff <- 0b11110111
120 125 etat <- 0
121 126 call afficherHorloge
122 127  
... ... @@ -211,6 +216,27 @@ afficherDi:
211 216 ret
212 217  
213 218 ; Logique
  219 +
  220 +agir1s:
  221 + inc d0
  222 + ; Met à jour les registres de temps, active agir10s ou agirHeur si nécessaire
  223 + inc t0
  224 + si t0-(t0/5)*5 != 0 saut ret ; Continue si on est sur un multiple de 10 secondes
  225 + call agir10s
  226 + si t0 < 30 saut ret ; Continue si on est sur un multiple de 60 secondes
  227 + t0 <- 0
  228 + inc t1
  229 + si t1 < 60 saut ret ; Continue si on est sur un multiple de 60 minutes
  230 + t1 <- 0
  231 + inc t2
  232 + si t2 & 0b00011111 >= 7 saut agir1sHeur ; Continue si il est minuit
  233 + t2 <- t2 + 0b00100000 ; Jour suivant
  234 + t2 <- t2 & 0b11100000 ; Heure à minuit
  235 + si t2 >= 0b11100000 alors t2 <- 0b00000000 ; Si on est dimanche soir, on revient à lundi matin
  236 +agir1sHeur:
  237 + call agirHeur
  238 + ret
  239 +
214 240 agir10s:
215 241 ; Initialise une lecture ADC
216 242  
... ... @@ -244,6 +270,8 @@ boundTemperature:
244 270 si compteur > 200 alors compteur <- 200
245 271 ret
246 272  
  273 +ret:
  274 + ret
247 275 reti:
248 276 reti
249 277  
... ... @@ -496,22 +524,7 @@ retour:
496 524  
497 525 ; Interruption Watchdog
498 526 watchdog:
499   - ; Met à jour les registres de temps, active agir10s ou agirHeur si nécessaire
500   - inc t0
501   - si t0-(t0/5)*5 != 0 saut reti ; Continue si on est sur un multiple de 10 secondes
502   - call agir10s
503   - si t0 < 30 saut reti ; Continue si on est sur un multiple de 60 secondes
504   - t0 <- 0
505   - inc t1
506   - si t1 < 60 saut reti ; Continue si on est sur un multiple de 60 minutes
507   - t1 <- 0
508   - inc t2
509   - si t2 & 0b00011111 >= 7 saut watchdogHeure ; Continue si il est minuit
510   - t2 <- t2 + 0b00100000 ; Jour suivant
511   - t2 <- t2 & 0b11100000 ; Heure à minuit
512   - si t2 >= 0b11100000 alors t2 <- 0b00000000 ; Si on est dimanche soir, on revient à lundi matin
513   -watchdogHeure:
514   - call agirHeur
  527 + call agir1s
515 528 reti
516 529  
517 530 ; Interruption ADC
... ... @@ -520,21 +533,40 @@ adc:
520 533 si ADCH < reference - 5 saut allumerChaudiere
521 534 reti
522 535 allumerChaudiere:
523   - PORTC <- 0x01
  536 + PORTG@IO <- 0xFF
524 537 reti
525 538 eteindreChaudiere:
526   - PORTC <- 0x00
  539 + PORTG@IO <- 0x00
527 540 reti
528 541  
529 542 ; Interruption timer
530 543 timer:
  544 + ; Sauvegarde de l'état
  545 + PUSH temp
  546 + PUSH r16
  547 + PUSH r17
  548 +
531 549 ; Affiche le digit suivant sur l'afficheur 7seg
532   - lsr selaff
533   - si selaff < 0b00001111 alors selaff <- 0b11110111
534   - PORTC@IO <- selaff
535   - si selaff = 0b11110111 alors PORTA@IO <- d3
536   - si selaff = 0b01111011 alors PORTA@IO <- d2
537   - si selaff = 0b00111101 alors PORTA@IO <- d1
538   - si selaff = 0b00011110 alors PORTA@IO <- d0
  550 + temp <- PORTC@IO
  551 + lsr temp
  552 + si temp < 0b00001111 alors temp <- 0b11110111
  553 + PORTC@IO <- temp
  554 + si temp = 0b11110111 alors PORTA@IO <- d3
  555 + si temp = 0b01111011 alors PORTA@IO <- d2
  556 + si temp = 0b00111101 alors PORTA@IO <- d1
  557 + si temp = 0b00011110 alors PORTA@IO <- d0
  558 +
  559 + ; Watchdog artificiel
  560 + inc tt
  561 + if tt < 244 saut timerRestore
  562 + tt <- 0
  563 + call agir1s
  564 +
  565 +timerRestore:
  566 + ; Restoration de l'état
  567 + POP r17
  568 + POP r16
  569 + POP temp
  570 +
539 571 reti
540 572  
... ...