stm32f4xx-hal icon indicating copy to clipboard operation
stm32f4xx-hal copied to clipboard

stm32f401 i2c can not work , Addr Flag Not Setting with the I2C Communication

Open flyingyizi opened this issue 3 years ago • 0 comments

case: examples/ssd1306-image.rs mcu: stm32f401 in proteus hal version: stm32f4xx-hal = "0.13.2"

problem:

through proteus's I2C debugger, find only occurs "S 78 A P", then the MCU hang. the final positon is in I2c::write_bytes.

    fn write_bytes(&mut self, addr: u8, bytes: impl Iterator<Item = u8>) -> Result<(), Error> {
        ....
        // Wait until address was sent
        loop {
            // Check for any I2C errors. If a NACK occurs, the ADDR bit will never be set.
            let sr1 = self
                .check_and_clear_error_flags()
                .map_err(Error::nack_addr)?;

            // Wait for the address to be acknowledged
            if sr1.addr().bit_is_set() {
                break;
            }
        }
        ...
    }

through the i2c transaction, we know i2c slave(ssd1306) already returned ACK. why the problem occours.

thanks.

flyingyizi avatar Oct 26 '22 07:10 flyingyizi