.equ PINC = 0x06 ; définition des adresses des ports .equ DDRC = 0x07 .equ PORTC = 0x08 .equ RAMEND = 0x21FF .equ SPH = 0x3E .equ SPL = 0x3D .equ UBRR0H = 0x00C5 .equ UBRR0L = 0x00C4 .equ UCSR0A = 0x00C0 .equ UCSR0B = 0x00C1 .equ UCSR0C = 0x00C2 .equ UDR0 = 0x00C6 .equ TCCR0A = 0x24 .equ TCCR0B = 0x25 .equ TIMSK0 = 0x6E .equ TIFR0 = 0x35 .def test = r19 .def numero = r20 .def ancienNumero = r21 .org 0x0000 ; Vecteur RESET jmp debut .org 0x002E ; Interruption du timer jmp tm .org 0x0080 touche: .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22, 0x81, 0x21 ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, # debut: ; initialisation du pointeur de pile ldi r28,low(RAMEND) ldi r29,high(RAMEND) out SPL, r28 out SPH, r29 ; Ports pour la touche de clavier DDRC@IO <- 0xFF ; Port série 16 MHz 2400 Baud UBRR0H <- 3 UBRR0L <- 64 UCSR0A <- 0b00000110 UCSR0B <- 0b00011000 UCSR0C <- 0b00000110 ; Timer toutes les 65 ms TCCR0A@IO <- 0x00 TCCR0B@IO <- 0b00000101 TIMSK0 <- 0x01 TIFR0 <- 0x01 sei test <- 0 numero <- 255 ancienNumero <- 255 boucle: sleep saut boucle reti: reti tm: ; On teste la touche courante PORTC@IO <- touche@ROM[test] si PINC@IO = touche@ROM[test] alors numero <- test ; On prépare la touche suivante inc test ; Si on est arrivé à la fin du test on recommence si test > 11 alors test <- 0 ; Si le numéro est différent du précédent (~ a changé) on l'envoie si numero = test saut reti si numero < 10 alors UDR0 <- 48 + numero si numero = 10 alors UDR0 <- 42 si numero = 11 alors UDR0 <- 35 ancienNumero <- numero reti