Problem mit atMega32, Pcf8574 & LCD

Gast #723529
Lesenswert?

Hallo, ich weis wurde hier schon ab und zu diskutiert(mit4*20), aber 
eine lösung habe ich leider nicht wirklich gefunden
Ich habe einen Atmega32 und wollte über I2C ein LCD 16*2 ansteuern.

die Ports am PCF8574 sind wie im Datenblatt beschalten.
Mein Problem ist das das Display keine Reagtion zeigt.
Das Display funktioniert direkt am Mega32, also ein defekt des disp kan 
man ausschließen.
im Programm habe ich zum test noch eine andere anbindung zu i2C die 
Funktioniert, also I2C ports auch OK.
1
$regfile = "m32def.dat"
2
$framesize = 32
3
$swstack = 32
4
$hwstack = 32
5
$crystal = 1000000
6
$lib "Lcd_i2c.lib"                                          'My i2c driver for the LCD
7
Config I2cdelay = 1
8
Const Pcf8574_lcd = &H40                                    'Defines the address of the I/O expander for LCD
9
Config Scl = Portc.0                                        'Configure i2c SCL
10
Config Sda = Portc.1                                        'Configure i2c SDA
11
Dim _lcd_e As Byte                                          'Needed to control 4 line LCD
12
_lcd_e = 128                                                'Upper half of 4-line display is selected
13
Dim A As Byte
14
Config Lcd = 16 * 2                                         'configure lcd screen
15
Cls                                                         'clear the LCD display
16

17
'Cursor Off Noblink                                          'hide cursor
18
'Wait 1                                                      'wait a moment
19
'Cursor On Blink                                             'show cursor
20
'Wait 1                                                      'wait a moment
21
'Display Off                                                 'turn display off
22
'Wait 1                                                      'wait a moment
23
'Display On
24

25

26
Do
27

28
  Cls
29
   Locate 2 , 10                                            'that 
30
   Lcd "Test"
31
 I2cstart                                                    'start condition
32
   I2cwbyte &H90                                            '10010000  144                                          'Adress   Dez 144 90H B10010000
33
   I2cwbyte &B00000000                                      '00000000  0
34
   I2cwbyte &B10111111                                      '10111111  191
35
   I2cwbyte &B00000011                                      '00000011  3
36
   I2cwbyte &B00001111                                      '00001111  15 Ausgang
37
    Waitms 400
38
I2cstop
39
                                                    'start condition
40
   I2cstart                                                 'start condition
41
I2cwbyte &H90                                               '10010000  144                                          'Adress   Dez 144 90H B10010000
42
I2cwbyte &H00                                               '00000000  0
43
I2cwbyte &H7F                                               '01111111  127
44
I2cwbyte &H02                                               '00000010  2
45
I2cwbyte &H0F                                      '00001111  15 Ausgang
46
    Waitms 400
47
I2cstop
48
Loop
49
End
Gast #723694
Lesenswert?

Sorry einige Komentare sind noch aus der lcd_i2c_demo.bas  .

PCF |  DISPL.
________
P0  | DB4
P1  | DB5
P2  | DB6
P3  | DB7
P4  | RS
P5  |
P6  |
P7  | E

PCF | Mega32
INT |
SDA | SDA (Wiederstand gegen 5V)
SCL | SCL (Wiederstand gegen 5V)

A0,A1,A2,PIN8(VSS) nach GND

VDD nach 5V

Display
R/W,DB0,DB1,DB2,DB3 Nach GND
Beitrag #5014912 wurde von einem Moderator gelöscht.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren