;______________________________________ ; GESTION DE LCD I2C ; Matériel : ATtiny 45/85 4MHz 5V ; LCD1602 I²C ; (c) sammy76.free.fr ; V1.0 2016/06/01 Juin 2016 ;______________________________________ ; V1.0 ESSAI ; ATtiny45 - 8MHz interne ; +-\/-+ ; PB5 1|- -|8 Vcc ;Trigger PB3 2|- -|7 PB2 SENSELED ; Echo PB4 3|- -|6 PB1 SDA ; GND 4|- -|5 PB0 SCL ; +----+ ;Registres utilisés r16 (A),r19 (Adresse I²C=ADR), r20 (DATA) ; .include "../includes/tn85def.inc" .cseg .define F_CPU 16500000 ;16.5MHz .def A = r16 ; .equ SENSELED=PB1 ; SENSELED pin (Output on AVR) ;----------------------------------------------------------------- .org 0000 ;************************************************ ;* Interrupt Vectors * ;************************************************ zRESET: ; Reset Handler rjmp ON_RESET zINT0addr: ; External Interrupt 0 reti zPCI0addr: ; Pin change Interrupt Request 0 reti zOC1Aaddr: ; Timer/Counter1 Compare Match 1A reti zOVF1addr: ; Timer/Counter1 Overflow reti zOVF0addr: ; Timer/Counter0 Overflow reti zERDYaddr: ; EEPROM Ready reti zACIaddr: ; Analog comparator reti zADCCaddr: ; ADC Conversion ready reti zOC1Baddr: ; Timer/Counter1 Compare Match B reti zOC0Aaddr: ; Timer/Counter0 Compare Match A reti zOC0Baddr: ; Timer/Counter0 Compare Match B reti zWDTaddr: ; Watchdog Time-out reti ;rjmp WDTinterrupt zUSI_STARTaddr: ; USI START reti zUSI_OVFaddr: ; USI Overflow reti ;***** Include modules .include "../utils/i2c_attiny.inc" .include "../utils/lcd_.inc" .include "../utils/wait.inc" .include "../utils/DS3231.inc" ;MACRO ;______________________________________ ; SETUP ;______________________________________ ON_RESET: ldi A, LOW(RAMEND) ;Setup of stack pointer 0x15F out SPL, A ldi A, HIGH(RAMEND) out SPH, A ldi A, 0b10000000 ;Attention, ces 2 instructions sont importantes pour le changement de fréquence (sécurité AVR) out CLKPR,A ldi A, 0b0000000 ;divise par 0le clock RC de 8MHz, donc 8MHz out CLKPR,A ;Eteint le CAN cbi ADCSRA, ADEN ;switch Analog to Digitalconverter OFF ;______________________________________ ; BOUCLE PRINCIPALE ;______________________________________ rcall LCD_Init ldi DATA,0x40 ;chr 0 rcall LCD_DATA_write_cmd ldi ZL,LOW(copyright<<1) ldi ZH,HIGH(copyright<<1) rcall LCD_write_string ldi DATA,0x48 ;chr 1 rcall LCD_DATA_write_cmd ldi ZL,LOW(deg<<1) ldi ZH, HIGH(deg<<1) rcall LCD_write_string; ldi DATA,0x50 ;chr 2 rcall LCD_DATA_write_cmd ldi ZL, LOW(e_acc<<1) ldi ZH, HIGH(e_acc<<1) rcall LCD_write_string; MAIN_LOOP: rcall DS3231_read_all rcall LCD_clear ldi ZL, LOW(txt1<<1) ldi ZH, HIGH(txt1<<1) rcall LCD_write_string ldi DATA,0xC0 ;Ligne 2 1100 0000 0x40 rcall LCD_DATA_write_cmd ldi ZL, LOW(date_txt<<1) ldi ZH, HIGH(date_txt<<1) rcall LCD_write_string_sram ldi A, 1 rcall Waitseconds rcall LCD_clear ldi ZL, LOW(txt3<<1) ldi ZH, HIGH(txt3<<1) rcall LCD_write_string ldi DATA,0xC3 ;Ligne 2 1100 0101 0x43 rcall LCD_DATA_write_cmd ldi ZL, LOW(temp_txt<<1) ldi ZH, HIGH(temp_txt<<1) rcall LCD_write_string_sram rcall I2CStop BOUCLE: rcall CLIGNOTE END: ldi A, 1 rcall Waitseconds RJMP MAIN_LOOP ; MAIN LOOP DOES NOTHING (YET). ;______________________________________ CLIGNOTE: sbi DDRB,SENSELED SBI PORTB,SENSELED ;Allume LED ldi A, 200 ;200ms rcall WaitMiliseconds CBI PORTB,SENSELED ;ETeind LED ret ;------------------------------------------------------------------ copyright: .db 0b01110, 0b10101, 0b11011, 0b11001, 0b11001, 0b11011, 0b10101, 0b01110,0xFF,0 deg: .db 0b00110, 0b01001, 0b01001, 0b00110, 0b00000, 0b00000, 0b00000, 0b00000,0xFF,0 e_acc: .db 0b00010, 0b00100, 0b01110, 0b10001, 0b11111, 0b10000, 0b01110, 0b00000,0xFF,0 txt1: .db "Nous sommes le :", 0xFF,0 txt3: .db "La temp",2,"rature :", 0xFF,0 .dseg .org 0x60 now: .byte 0x12 date_txt: .byte 17 ;08.11.2016 06:16 +0xFF temp_txt: .byte 6 ;25.25 +0xFF