Ich hoffe ihr könnt mir helfen. und zwar wollte Ich mit einem PCA9554AD Portexpander und einem LM75 Arbeiten und das ganze über I²C.mein Problem es funktioniert weder der LM75 abzufragen noch den PCA9554AD. Ich habe einen 4,7kOhm PullUp an SDA und an SCL. sowie einen 100n Kondensator an VCC/GND. Adresse vom PCA9554AD ist 01110000 ich habe es auch mit 01000000 Probiert aber erfolglos mein Code dazu:
1 | |
2 | $regfile = "m644pdef.dat" |
3 | $crystal = 16000000 |
4 | '$sim 'Frequenz 16MhZ |
5 | $baud = 2400 'Baudrate Com1 zum PC |
6 | $baud1 = 2400 |
7 | $timeout = 20000000 'Timeout für Serial In 10 Sekunden |
8 | $hwstack = 90 |
9 | $swstack = 64 |
10 | $framesize = 64 |
11 | $lib "i2c_twi.lib" |
12 | '############################## 1²C Bus ########################## |
13 | Config Sda = Portc.1 'Pin23 |
14 | Config Scl = Portc.0 |
15 | Config Portc.1 = Output |
16 | Config Portc.0 = Output 'Pin22 |
17 | I2cinit |
18 | Waitms 200 |
19 | ''''Portexpander 1 Konfigurieren |
20 | I2cstart |
21 | I2cwbyte &B01110000 |
22 | I2cwbyte 3 |
23 | I2cwbyte &B00000000 |
24 | I2cstop |
25 | Waitms 25 |
26 | If Err = 0 Then |
27 | Print #2 , "Port1 OK adresse 0111" |
28 | Else |
29 | Print #2 , "Port1 Fehler" |
30 | End If |
31 | |
32 | I2cstart |
33 | I2cwbyte &B01000000 |
34 | I2cwbyte 3 |
35 | I2cwbyte &B00000000 |
36 | I2cstop |
37 | Waitms 25 |
38 | If Err = 0 Then |
39 | Print #2 , "Port1 OK adresse 0100" |
40 | Else |
41 | Print #2 , "Port1 Fehler" |
42 | End If |
43 | Const Port1_write = &B01110000 |
44 | Const Port1_read = &B01110001 |
45 | '############################# Anzeige Testen ######################## |
46 | Anzeige_test: |
47 | Print #2 , "Anzeige Test2" |
48 | Dim Z As Integer |
49 | Z = 0 |
50 | Do |
51 | I2cstart |
52 | I2cwbyte Port1_write |
53 | I2cwbyte 1 |
54 | I2cwbyte &B11111111 |
55 | I2cstop |
56 | If Err = 0 Then |
57 | Print #2 , "Port1 OK" |
58 | Else |
59 | Print #2 , "Port1 Fehler" |
60 | End If |
61 | Wait 1 |
62 | I2cstart |
63 | I2cwbyte Port1_write |
64 | I2cwbyte 1 |
65 | I2cwbyte &B00000000 |
66 | I2cstop |
67 | If Err = 0 Then |
68 | Print #2 , "Port1 OK" |
69 | Else |
70 | Print #2 , "Port1 Fehler" |
71 | End If |
72 | Print #2 , "Z= " ; Z |
73 | Z = Z + 1 |
74 | Waitms 500 |
75 | Loop Until Z = 8 |
76 | |
77 | Locate 3 , 1 |
78 | Lcd "Erfolgreich" |
79 | |
80 | Return |