Hello
sorry for not answering earlier.
I somehow reproduced the issue this morning and please find below my first findings:
First I used another NUCLEO board as a master and used the test code below
char buf[] = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30};
i2c.write(ADDR, buf, SIZE);
wait(1);
i2c.write(ADDR, buf, SIZE);
the slave is properly getting the answer and printing result :
Read A: 1234567890
Read A: 1234567890
Then next thing I did is to remove the wait(1); in the master code.
char buf[] = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30};
i2c.write(ADDR, buf, SIZE);
wait(1);
i2c.write(ADDR, buf, SIZE);
In this case, I reproduce a similar issue as you see and I will try to investigate how to recover from the error.
Nevertheless, there is an easy way to avoid the problem on the slave side. In order to keep real time answer, it's better to get rid of the printf (useful for quick debug, but not adapted to real time answer needed by an I2C slave).
So if by removing call to printf, I have the test working fine:
case I2CSlave::WriteAddressed:
slave.read(buf, 10);
printf("Read A: %s\n", buf);
break;
I could check on a scope that the 10 bytes are well received, and SCL as well as SDA are back to normal (high) state.
So please remove the call to printf, or add a suitable pause / wait on the master side to allow printf to happen before sending the next command
cheers
Laurent
I am having a problem using NUCLEO-F401RE board for testing the i2c slave. I was using the mbed OS 5 i2c slave example (https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/interfaces/digital/I2CSlave/) with the bit rate standard 100K bit/s. I used the Total Phase Aardvark I2C host adapter sending bytes (8 bytes) to NUCLEO-F401RE board. The NUCLEO-F401RE i2c slave always holds down the SCL line forever in middle of the data transfer, which can be viewed clearly by a oscilloscope or a I2C protocol analyzer. Please help!
The I2C slave testing project is here:
Import programI2CSlaveTest
mbed OS-5 I2C Slave using Nucleo-F401RE board.
Last commit 22 Aug 2016 by Jingxi Zhang
The following is the snippet of the test code:
NUCLEO-F401RE I2C slave test