hallo
ich hab ein I2C lcd fuer die c-control I m-unit 2 conrad Artikel-Nr.: 198330 - 62 das ich gerne an einem RN-Control 1.4 verwenden wuerde.
dazu wollte ich die basic++ ansteuerung in Bascom uebersetzen, was mir nicht gelang.
hier der orginal basic++ code:
Code:
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'III BASIC++ DEMO ZUM BASIC-COMPUTER UNIT M 1.2/2.0 IIIII
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'--------------------------------------------------------------------
' Beispiel zum BASIC-COMPUTER mit dem Programmer/Application-Board
'--------------------------------------------------------------------
' LIBRARY: LCD_INIT() INIT LCD AT IICBUS (PCF8574)
' L1(position) SET CURSOR TO LINE1 POSITION position
' L2(position) SET CURSOR TO LINE2 POSITION position
' LCD_CLR CLEAR DISPLAY
' LCDWRITE(CMD,DATA) CMD=0/20h for WRITE COMMAND/WRITE DATA
'-------------------------------------------------------------------
'-------------------------------------------------------
'--- PCF 8574 LCD DRIVER AT ADDR 7 / EXT BYTEPORT 10 ---
'-------------------------------------------------------
Function Lcd_write(buf As Byte , Lcddata As Byte)
Define Extport Byteport[10]
Define Outbyte As Byte
'--------- ------WRITE HI NIBBLE ------------------------
Outbyte = Buf Or(lcddata Shr 4)
Extport = Outbyte Or 01000000b
Extport = Outbyte And 10111111b
'--------------- WRITE LO NIBBLE ------------------------
Outbyte = Buf Or(lcddata And 0fh)
Extport = Outbyte Or 01000000b
Extport = Outbyte And 10111111b
End Function
'-----------------------------------------------------
Function Lcd_clr()
Lcd_write(0 , 02h)
Lcd_write(0 , 01h)
Pause 2
End Function
'----------------------------------------------------
Function Lcd_init()
Define Extport Byteport[10]
Extport = 0
Lcd_write(0 , 38h) '0=WRITE CMD
Extport = 00000010b
Extport = 01000010b
Extport = 00000010b
Lcd_write(0 , 28h)
Lcd_write(0 , 0ch)
Lcd_clr()
End Function
'----------------------------------------------------
Function Line1(pos As Byte)
Lcd_write(0 , 7fh + Pos)
End Function
'----------------------------------------------------
Function Line2(pos As Byte)
Lcd_write(0 , Bfh + Pos)
End Function
'----------------------------------------------------
und hier soweit ich kam in bascom:
Code:
'--------------------------------------------------------------------
' LIBRARY: LCD_INIT() INIT LCD AT IICBUS (PCF8574)
' L1(position) SET CURSOR TO LINE1 POSITION position
' L2(position) SET CURSOR TO LINE2 POSITION position
' LCD_CLR CLEAR DISPLAY
' LCDWRITE(CMD,DATA) CMD=0/20h for WRITE COMMAND/WRITE DATA
'-------------------------------------------------------------------
'--- PCF 8574 LCD DRIVER AT ADDR 7 / EXT BYTEPORT 10 ---
'-------------------------------------------------------
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 19200
Declare Sub Lcd_write(byval Buf As Byte , Byval Lcddata As Byte)
Declare Sub Lcd_clr()
Declare Sub Lcd_init()
Declare Sub Line1(byval pos As Byte)
Declare Sub Line2(byval Pos As Byte)
Config Scl = Portc.0
Config Sda = Portc.1
I2cinit
Dim X As Byte
Dim Y As Byte
Dim Outbyte As Byte
'-------------------------------------------------------
Sub Lcd_write(buf As Byte , Lcddata As Byte)
I2cstart
'--------- ------WRITE HI NIBBLE ------------------------
Outbyte = &H20 Or(shift Lcddata , Right , 4)
X = Outbyte Or &B01000000
I2cwbyte X
X = Outbyte And &B10111111
I2cwbyte X
'--------------- WRITE LO NIBBLE ------------------------
Y = lcddata And &H0F
Outbyte = Buf Or Y
X = Outbyte Or &B01000000
I2cwbyte X
X = Outbyte And &B10111111
I2cwbyte X
I2cstop
End Sub
'-----------------------------------------------------
Sub Lcd_clr()
Lcd_write 0 , &H02
Lcd_write 0 , &H01
Waitms 2
End Sub
'----------------------------------------------------
Sub Lcd_init()
I2cstart
I2cwbyte 0
I2cstop
Lcd_write 0 , &H38 '0=WRITE CMD
I2cstart
I2cwbyte &B00000010
I2cwbyte &B01000010
I2cwbyte &B00000010
I2cstop
Lcd_write 0 , &H28
Lcd_write 0 , &H0C
Lcd_clr
End Sub
'----------------------------------------------------
Sub Line1(pos As Byte)
Lcd_write 0 , &H7F + Pos
End Sub
'----------------------------------------------------
Sub Line2(pos As Byte)
Lcd_write 0 , &HBF + Pos
End Sub
'----------------------------------------------------
Lcd_init
' wuerde 'DA' schreiben
Lcd_write &H20 , &H44
Lcd_write &H20 , &H41
hauptproblem ist bei diesem high/low nibble.
in der zeile 39 mit dem bitshift hat mir der compiler immer ne fehlermeldung von wegen wert passt nicht in die variable gegeben. jetzt sagt er es grad nicht.
aber funktionieren tuts jedenfalls nicht.
gefunden hab ich nichts dazu.
danke
Lesezeichen