Hallo Leute,
ich versuche hier eine Kommunikation von 2 Pic's per I2C herzustellen,
aber leider will das nicht so richtig passen. Der Slave blockiert
irgendwann den Bus!
1) nach Start und Adresse -> das Ack/Nack wird nicht ausgeführt
2) nach Start, Adresse und Nack-> Master will Stop senden aber Slave
hält den Clk weiter low!
Master sendet im Vordergrung und der Slave empfängt im INT!
Vom Master kommen immer nur WR-Telegramme!!
1 | I2C_MODULE inf= I2C1;
|
2 |
|
3 | INT_SOURCE eMaster;
|
4 | INT_SOURCE eSlave;
|
5 | INT_SOURCE eBusColision;
|
6 |
|
7 | switch(inf)
|
8 | {
|
9 | case I2C1:
|
10 | eMaster= INT_I2C1M;
|
11 | eSlave= INT_I2C1S;
|
12 | eBusColision= INT_I2C1B;
|
13 | break;
|
14 | }
|
15 |
|
16 | if(INTGetFlag(eSlave)) //INT_SOURCE_I2C_SLAVE(inf)))
|
17 | {
|
18 | INTClearFlag(eSlave);
|
19 |
|
20 | I2C_STATUS MyStatus;
|
21 | MyStatus= I2CGetStatus(inf);
|
22 | u08 SendByte;
|
23 |
|
24 | if ((MyStatus & I2C_SLAVE_READ) == 0 && I2CReceivedByteIsAnAddress(inf) == 1)
|
25 | {
|
26 | // is write to slave
|
27 | // is an Adress
|
28 | SendByte= I2CGetByte(inf);
|
29 | I2CSlaveClockRelease(inf);
|
30 | }
|
31 | else if ((MyStatus & I2C_SLAVE_READ) == 0 && I2CReceivedByteIsAnAddress(inf) == 0)
|
32 | {
|
33 | // is write to slave
|
34 | // is DataByte
|
35 | SendByte= I2CGetByte(inf);
|
36 | I2CSlaveClockRelease(inf);
|
37 | }
|
38 | else if ((MyStatus & I2C_SLAVE_READ) == 1 && I2CReceivedByteIsAnAddress(inf) == 1)
|
39 | {
|
40 | // is read from slave
|
41 | // is an Adress
|
42 | SendByte= I2CGetByte(inf);
|
43 | I2CSendByte( inf, 0x07); // <- Dummy
|
44 | }
|
45 | else if ((MyStatus & I2C_SLAVE_READ) == 1 && I2CReceivedByteIsAnAddress(inf) == 0)
|
46 | {
|
47 | // is read from slave
|
48 | // is DataByte
|
49 | I2CSendByte( inf, 0x70); // <- Dummy
|
50 | }
|
51 | }
|
eigendlich ist das das gleiche was MC auch in den Beispielen macht....?
Vielleicht hat einer von euch noch eine Idee was falsch ist.
mfg
Stephan