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
@@ -6,6 +6,9 @@ @@ -6,6 +6,9 @@
6 .equ PINC = 0x06 6 .equ PINC = 0x06
7 .equ DDRC = 0x07 7 .equ DDRC = 0x07
8 .equ PORTC = 0x08 8 .equ PORTC = 0x08
  9 +.equ PING = 0x12
  10 +.equ DDRG = 0x13
  11 +.equ PORTG = 0x14
9 12
10 .equ WDTCSR = 0x60 13 .equ WDTCSR = 0x60
11 14
@@ -38,7 +41,7 @@ @@ -38,7 +41,7 @@
38 .def t2 = r8 ; Jour (3 premiers bits) et Heure (5 derniers bits) 41 .def t2 = r8 ; Jour (3 premiers bits) et Heure (5 derniers bits)
39 .def t1 = r9 ; Minutes 42 .def t1 = r9 ; Minutes
40 .def t0 = r10 ; Secondes / 2 43 .def t0 = r10 ; Secondes / 2
41 -.def selaff = r11 ; Digit en cours d'affichage 44 +.def tt = r11 ; Watchdog artificiel
42 45
43 ; Nommage des adresses RAM utilisées 46 ; Nommage des adresses RAM utilisées
44 47
@@ -88,15 +91,16 @@ debut: @@ -88,15 +91,16 @@ debut:
88 ; Ports parallèles 91 ; Ports parallèles
89 DDRA@IO <- 0xFF 92 DDRA@IO <- 0xFF
90 DDRC@IO <- 0xFF 93 DDRC@IO <- 0xFF
  94 + DDRG@IO <- 0xFF
91 95
92 ; Watchdog 96 ; Watchdog
93 - WDTCSR <- 0b00010000  
94 - WDTCSR <- 0b01000111 97 + ;WDTCSR <- 0b00010000
  98 + ;WDTCSR <- 0b01000111
95 99
96 ; Timer 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 ; Interruptions externes 105 ; Interruptions externes
102 EIMSK <- 0b00001111 106 EIMSK <- 0b00001111
@@ -109,14 +113,15 @@ debut: @@ -109,14 +113,15 @@ debut:
109 ADCSRA <- 0b10011101 ; TODO Auto-trigger ? 113 ADCSRA <- 0b10011101 ; TODO Auto-trigger ?
110 114
111 sei 115 sei
  116 + wdr
112 117
113 ; Initialisation des valeurs 118 ; Initialisation des valeurs
114 ; Mercredi 12h34'56 119 ; Mercredi 12h34'56
115 t2 <- 0b01001100 120 t2 <- 0b01001100
116 t1 <- 34 121 t1 <- 34
117 t0 <- 28 122 t0 <- 28
  123 + tt <- 0
118 124
119 - selaff <- 0b11110111  
120 etat <- 0 125 etat <- 0
121 call afficherHorloge 126 call afficherHorloge
122 127
@@ -211,6 +216,27 @@ afficherDi: @@ -211,6 +216,27 @@ afficherDi:
211 ret 216 ret
212 217
213 ; Logique 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 agir10s: 240 agir10s:
215 ; Initialise une lecture ADC 241 ; Initialise une lecture ADC
216 242
@@ -244,6 +270,8 @@ boundTemperature: @@ -244,6 +270,8 @@ boundTemperature:
244 si compteur > 200 alors compteur <- 200 270 si compteur > 200 alors compteur <- 200
245 ret 271 ret
246 272
  273 +ret:
  274 + ret
247 reti: 275 reti:
248 reti 276 reti
249 277
@@ -496,22 +524,7 @@ retour: @@ -496,22 +524,7 @@ retour:
496 524
497 ; Interruption Watchdog 525 ; Interruption Watchdog
498 watchdog: 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 reti 528 reti
516 529
517 ; Interruption ADC 530 ; Interruption ADC
@@ -520,21 +533,40 @@ adc: @@ -520,21 +533,40 @@ adc:
520 si ADCH < reference - 5 saut allumerChaudiere 533 si ADCH < reference - 5 saut allumerChaudiere
521 reti 534 reti
522 allumerChaudiere: 535 allumerChaudiere:
523 - PORTC <- 0x01 536 + PORTG@IO <- 0xFF
524 reti 537 reti
525 eteindreChaudiere: 538 eteindreChaudiere:
526 - PORTC <- 0x00 539 + PORTG@IO <- 0x00
527 reti 540 reti
528 541
529 ; Interruption timer 542 ; Interruption timer
530 timer: 543 timer:
  544 + ; Sauvegarde de l'état
  545 + PUSH temp
  546 + PUSH r16
  547 + PUSH r17
  548 +
531 ; Affiche le digit suivant sur l'afficheur 7seg 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 reti 571 reti
540 572