;______________________________________ ; MODULE LCD I2C ; Matériel : ATtiny 45/85 4MHz mini 5V ; ; (c) sammy76.free.fr ; V1.0 2016/06/01 Juin 2016 ;______________________________________ ; V1.0 ; ATtiny45 - 8MHz interne ; +-\/-+ ; PB5 1|- -|8 Vcc ; SCL PB3 2|- -|7 PB2 ; SDA PB4 3|- -|6 PB1 SENSELED ; GND 4|- -|5 PB0 ; +----+ ;ATtiny85 - 16.5MHz Digispark ;P0 : ;P1 : SENSELED (Interne) ;P2 : ;P3 : SCL ;P4 : SDA ;P5 : ; I2C Device addressing .equ LCD1602 = 0x3F ; LCD1602 address byte ;________________________________________________________________ ;LCD Init ;Registres utilisés : r16 (A),r19 (Adresse I²C=ADR), r20 (DATA),Z ;________________________________________________________________ LCD_Init: ;Configure l'I2C ldi ADR,LCD1602*2 rcall I2CInit LDI DATA,0 rcall DATA_write_byte ldi DATA,0x33 ;Init rcall LCD_DATA_write_cmd ldi DATA,0x32 ;Init rcall LCD_DATA_write_cmd ldi DATA,0x28 ;Function set 4bits/2lignes/ rcall LCD_DATA_write_cmd ldi DATA,0x0C ;Display control Display on/cursor on/Blinking off rcall LCD_DATA_write_cmd ldi DATA,0x06 ;Entry mode increment by 1, No shift rcall LCD_DATA_write_cmd ret ;________________________________________________________________ ;LCD WRITE STRING ;Registres utilisés : r16 (A),r19 (Adresse I²C=ADR), r20 (DATA),Z ;________________________________________________________________ LCD_write_string: lpm DATA, Z+ ;DATA=(Z) FLASH Z=Z+1 LCD_write: ser A ;0xFF cp DATA,A ;Si egal fin breq end_write_str rcall LCD_DATA_write_char ;Ecrire la donnée I2CWData ldi A, 2 rcall WaitMiliseconds ;5ms rjmp LCD_write_string end_write_str: ret LCD_write_string_sram: LD DATA, Z+ ;DATA=(Z) Z=Z+1 ser A ;0xFF cp DATA,A ;Si egal fin breq end_write_str_sram rcall LCD_DATA_write_char ;Ecrire la donnée I2CWData ldi A, 2 rcall WaitMiliseconds ;5ms rjmp LCD_write_string_sram end_write_str_sram: ret LCD_clear: ldi DATA,0x01 ;Clear display rcall LCD_DATA_write_cmd ldi A, 2 rcall WaitMiliseconds ret LCD_DATA_write_char: push DATA ;Sauve DATA rcall LCD_char_quartet pop DATA SWAP DATA ;echange quartet haut et bas rcall LCD_char_quartet ret LCD_char_quartet: andi DATA,0xF0 ori DATA,0x0D push DATA rcall DATA_write_byte pop DATA andi DATA,0xF9 rcall DATA_write_byte ret LCD_DATA_write_cmd: push DATA ;Sauve DATA rcall LCD_cmd_quartet pop DATA SWAP DATA ;echange quartet haut et bas rcall LCD_cmd_quartet ret LCD_cmd_quartet: andi DATA,0xF0 ori DATA,0x0C push DATA rcall DATA_write_byte pop DATA andi DATA,0xF8 rcall DATA_write_byte ret ;________________________________________________________________