Hallo Xaver,
ich verwende auch das 4x27-Wintek-Display von Pollin. Funktioniert eigentlich problemlos, ich bin sehr zufrieden.
Ich betreibe es mit der "lcd4e2.lbx", wie Ratber schon schrieb, sind dann die Belegungen allerdings festgelegt, es wird der komplette Port B (außer B.1) verwendet.
Du findest die genaue Beschaltung der Port´s in der Bascom-Hilfe.
Der Betrieb parallel zum ISP-Adapter ist problemlos. Zwar zeigt das Display ein paar wirre Zeichen während des Flashens, aber sonst passiert nix.
Das nachfolgende Programm habe ich geschrieben als Testprogramm (Anzeige Portstatus) für mein selbstgebautes Experimentierboard (Mega 8, I2C-Porterweiterung), es sollte aber auch bei Dir funktionieren.
Wenn der Bus nicht aktiv ist, wird der I2C-Status automatisch auf "Fault" gesetzt, der Rest vom Programm läuft trotzdem.
Vielleicht hilft´s Dir ja weiter, viele Grüße
Torsten
Code:
'*****************************************
' Test Program for Development Board
' Designed for Atmel AVR Mega 8
' Bascom Version 1.11.7.4
' 24.07.2005 T. Gietenbruch
'
' Hardware Configuration:
' -> LCD-Display at Port B
' -> Switches and LED´s at Port C
' -> Switches and LED´s at Port D
' -> I2C-Bus: SDA at PC4 / SCL at PC5
' -> PCF8574P 8-Bit-Extension at adress 64
'
'******************************************
'==========================================
' System Configurations
'==========================================
'Definition for Mega 8
$regfile "m8def.dat"
$crystal = 8000000
'$baud = 9600
'Library for I2C-Bus
$lib "i2c_twi.lbx"
'Library for 2-Processor LCD-Display
$lib "Lcd4e2.lbx"
'Configuration of LCD-Display
Config Lcd = 20 * 4
'Port Configurations
Config Portc = Input
Config Portd = Output
'==========================================
' Declarations
'==========================================
'Display part selection - variable name is fixed in library!
Dim ___lcde As Byte
'I2C-Bus variables
Dim I2c_ok As Bit
Dim I2c_state As String * 10
Dim Portpcf_1_out As Byte
Dim Portpcf_1_in As Byte
'Program variables
Dim Count As Integer
Dim T_count As Integer
Dim Led_no As Byte
'==========================================
' Initialising
'==========================================
'I2C-Bus write adress for PCF8574P - selectable with jumpers
Const Pcf1w_adr = 64
'Read adress is always write adress + 1
Const Pcf1r_adr = Pcf1w_adr + 1
'Initial values
Portpcf_1_in = &B11111111
Portpcf_1_out = &B10101010
Portd = &B11111111
I2c_ok = 0
Count = 0
Led_no = 0
'==========================================
' Main Program: Building LCD Display Mask
'==========================================
'Selection of upper LCD segment
___lcde = 0
'All following LCD commands are for the upper two lines
Cls
'Text for 1st line
Locate 1 , 1
Lcd "**** ATMEL RISC MEGA 8 ****"
'Text for 2nd line
Locate 2 , 1
Lcd "**** DEVELOPMENT BOARD ****"
'Switching the cursor off
Cursor Off
'Selection of lower LCD segment
___lcde = 1
'All following LCD commands are for the lower two lines
Cls
'Text for 3rd line
Locate 1 , 1
Lcd " I2C-Bus:"
'Text for 4th line
Locate 2 , 1
Lcd " PC: PD:"
'Switching the cursor off
Cursor Off
'==========================================
' Main Program: Initializing I2C-Bus
'==========================================
'Initializing
I2cinit
'Print state "Search"
___lcde = 1
Locate 1 , 12
Lcd "Search..."
'Check if I2C-Bus is OK
While Count < 20 And I2c_ok = 0
Incr Count
I2cstart
I2cwbyte Pcf1w_adr
If Err = 1 Then
I2c_state = "Fault"
I2cstop
Else
I2c_ok = 1
I2c_state = "OK"
I2cwbyte Pcf1w_adr
I2cwbyte Portpcf_1_out
End If
Wend
'Print final state of I2C-Bus
Locate 1 , 12
Lcd " "
Locate 1 , 12
Lcd I2c_state
'==========================================
' Main Program: Monitoring Port States
'==========================================
Do
'Read and print PIN state of PCF8574P
If I2c_ok = 1 Then
If T_count > 30 Then
Toggle Portpcf_1_out
I2cstart
I2cwbyte Pcf1w_adr
I2cwbyte Portpcf_1_out
T_count = 0
End If
I2cstart
I2cwbyte Pcf1r_adr
I2crbyte Portpcf_1_in , Ack
'I2cstop
Locate 1 , 18
Lcd Bin(portpcf_1_in)
End If
If Count > 5 Then
Toggle Portd.led_no
Count = 0
Incr Led_no
If Led_no > 7 Then
Led_no = 0
End If
End If
'Print PIN state of Port C
Locate 2 , 6
Lcd Bin(pinc)
'Print PIN state of Port D
Locate 2 , 18
Lcd Bin(pind)
'Toggle Live Bit
Incr Count
Incr T_count
'End of main program endless loop
Loop
Lesezeichen