.equ PINA = 0x00 ; définition des adresses des ports .equ DDRA = 0x01 .equ PORTA = 0x02 .equ PINC = 0x06 .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 d2 = r19 .def d1 = r20 .def d0 = r21 .def select = r22 .org 0x0000 ; Vecteur RESET jmp debut .org 0x002E ; Interruption du timer jmp tm .org 0x0080 codeAff: ; Représentation des chiffres sur l'afficheur 7-segments .db 0b1111110, 0b001100, 0b0110111, 0b0011111, 0b1001101, 0b1011011, 0b1111011, 0b0001110, 0b1111111, 0b1011111 debut: ; initialisation du pointeur de pile ldi r28,low(RAMEND) ldi r29,high(RAMEND) out SPL, r28 out SPH, r29 ; Ports pour l'afficheur DDRA@IO <- 0xFF DDRC@IO <- 0xFF ; Port série 16 MHz 2400 Baud UBRR0H <- 3 UBRR0L <- 64 UCSR0A <- 0b00000110 UCSR0B <- 0b00011000 UCSR0C <- 0b00000110 ; Timer toutes les 2 ms TCCR0A@IO <- 0x00 TCCR0B@IO <- 0x04 TIMSK0 <- 0x01 TIFR0 <- 0x01 ; Initialisation des valeurs à envoyer sur le port série d2 <- 0 d1 <- 0 d0 <- 0 sei boucle: ; attend qu'un caractère arrive si (UCSR0a & 0x80) == 0 saut boucle R20 <- UDR0 d2 <- UDR0 / 100 d1 <- (UDR0 / 10) % 10 d0 <- UDR0 % 10 saut boucle tm: PortC@IO <- select si select = 0b10000000 alors PortA@IO <- codeAff@ROM[d2] si select = 0b01000000 alors PortA@IO <- codeAff@ROM[d1] si select = 0b00100000 alors PortA@IO <- codeAff@ROM[d0] lsl select si select = 0 alors select <- 0b00100000 reti