Hallo Forum Gemeinde und Bastler
Könntet mal jemeand die I2C Lib datei mal ansehen ob das so geht mit den Pollin I2C LCD
Hier datei
---------------------------------------------------------------------------------------------
Ist da verleicht irgendwie ein Port dreher drin oder so....
weil ich mit Basic oder was da ist nicht auskenne. ach ja der code in bascom ist der hier
----------------------------------------------------------------------------------------
Ich freue mich um eure Tipps und Ratschlege......
Gruß Thorsten Sch.
Könntet mal jemeand die I2C Lib datei mal ansehen ob das so geht mit den Pollin I2C LCD
Hier datei
---------------------------------------------------------------------------------------------
Code:
copyright = Kent Andersson
www = none
email = kent@smmab.se
comment = I2C LCD driver
libversion = 1.02
date = 31 march 2002
statement = You are free to use this code any way you like, if you are able to optimize
statement = it better, please send me an update on my e-mail.
history = No known bugs.
;define a constant named PCF8574_LCD pointing to the i2c address
;dimension _lcd_e as byte to control the E-lines (4 lines LCD:s)
;_lcd_e should have one of the following values
;128 to enable E1, 64 to enable E2, 192 to enable both E1 and E2 (cls, deflcdchar)
;Connect the following pins from PCF8574 to LCD
;
;P0 - D4
;P1 - D5
;P2 - D6
;P3 - D7
;P4 - RS
;P5 - RW (not used, set to 0 to ground for write)
;P6 - E2 (on 1 or 2 line display nc)
;P7 - E1
[_Init_LCD]
_Init_LCD:
*BASIC: waitms 50
ldi r16,&hc0 ; this is to make the initialization on both halfs of a 4-line LCD
Ldi _temp1, &h03 ; at init-time I call all routines before _lcd_e is loaded into r16
Rcall _Send_to_LCD
*BASIC: waitms 4
Rcall _Send_to_LCD
Rcall _Send_to_LCD
Ldi _temp1, &h02
Rcall _Send_to_LCD
Ldi _temp1, &h28
Rcall _Write_lcd_byte ;RS flag should to be 0, so jump directly to write byte
Ldi _temp1, &h08
Rcall _Write_lcd_byte
Ldi _temp1, &h0c
Rcall _Write_lcd_byte
Ldi _temp1, &h01
Rjmp _Write_lcd_byte
[END]
[_Write_lcd]
_Write_lcd:
* lds r16,{_lcd_e}
sbr r16,&h10 ;set RS flag (4 high bits is used as control)
rjmp _write_lcd_byte
_Lcd_Control:
* lds r16,{_lcd_e}
_write_lcd_byte:
push r24
Swap _temp1
Rcall _Write_lcd_Nibble
pop r24
_Write_lcd_nibble:
Cbr _temp1,&HF0 ; E1, E2, RW, RS low
_Send_to_LCD:
push r26
push r27
ldi r25,3
_send_3_times:
*BASIC: i2csend pcf8574_LCD,_temp1
eor _temp1,R16 ; Xor E1 and/or E2 to set them
; @genus(250)
ldi r26,0
_LCD_delay:
dec R26
brne _LCD_delay
Dec R25
Brne _send_3_times
eor _temp1,R16 ; Xor to restore to initial state (even number of times)
pop r27
pop r26
ret
[END]
weil ich mit Basic oder was da ist nicht auskenne. ach ja der code in bascom ist der hier
----------------------------------------------------------------------------------------
Code:
'*******************************************************************************
'*** Schreibt auf das I2C Lcd ; Bus geschwindigkeit ist 100khz ***
'*** Schaltet Pin 6 von PCF8574 aller 2 sec um ***
'!!! wenn keine anzeige auf dem LCD erscheint dann mit anderen I2C-Delay !!!
'!!! Werten probieren
'*** es wird die Bascom I2C Lib verwendet - evtl noch runterladenlade
$lib "Lcd_i2c.lib" 'ersetzt die Standard LCD Library
$regfile = "m8def.dat" 'verwendet den ATmega16 als µC
$crystal = 16000000 '16MHz Taktfrequenz
Const Pcf8574_lcd = &H40 'I2C Adresse &H40
Config I2cdelay = 15 'delay von 5=20µs=50kHz,10=10µs=100kHz;5=5µs=200KHz
Config Scl = Portc.5 'I2C SCL Pin
Config Sda = Portc.4 'I2C SDA Pin
Dim _lcd_e As Byte
_lcd_e = 128 'LCD im 4-Bit Mode betreiben
Dim A As Byte
Dim B As Byte
A = &B01000000 'pin 6 auf High
B = &B00000000 'pin 6 auf low
Do
Cls 'loesche das LCD Display
Locate 1 , 1
Lcd "***Hallo Welt***"
Locate 2 , 1
Lcd "ww.svens-projekte.de"
Waitms 200
'*** LCD Hintergrundbeleuchtung an- und ausschalten
I2csend &H40 , B 'Sendet an &H40 den wert b = Low an pin 6
'Pin 6 geht auf masse - Schaltet durch
Wait 2
I2csend &H40 , A 'Sendet an &H40 den wert A = High an pin 6
'Pin 6 heht auf 5v -
Wait 2
Loop
Ich freue mich um eure Tipps und Ratschlege......
Gruß Thorsten Sch.