8 years, 10 months ago.  This question has been closed. Reason: Off Topic

Is there are bug with the I2C for the STM32F407 Discovery board?

Hi,

I have got the i2c library working on the efm32 gecko but when I tried the mbed i2c on the stm32F407, the comms seems to be stuck when it transmit the first byte (slave address). I originally thought it was the device not acking back but when I used the stm32 hal library, it works flawlessly. I have also capture the i2c waveforms on the scope for both mbed and hal libraries. I have used the different mbed i2c write and read api functions but the same result. I used the shorter write and read commands on the efm32 which works without any issue.

mbed i2c example

#include "mbed.h"

const uint8_t I2C_ADDR = 0x68; 
const char cmd = 0x0E;

I2C i2c(PB_7, PB_6);

int main(void)
{
   char temp_read[2];
   i2c.frequency(100000);

   i2c.start();
    ack=i2c.write(I2C_ADDR);  
    ack=i2c.write(cmd);
    i2c.start();        
    ack=i2c.write(I2C_ADDR | 0x01); 
    temp_read[0]=i2c.read(1);     
    temp_read[1]=i2c.read(0); 
    i2c.stop();

   while(1) {}
}

mbed library - i2c capture

/media/uploads/paul2015nz/img-20150729-wa0012.jpeg

stm32 hal library - i2c capture

/media/uploads/paul2015nz/img-20150730-wa0000.jpeg

Paul

Question relating to:

I was having the same problem (still unsolved) using the Seeed arch max write and read was nak'ed. Looking at the i2c address 0x68, have you tried shifting it 1 bit left, as mbed is 8 bit address.

posted by David Fletcher 30 Jul 2015

Hi David,

Ok, you are right. I needed the 1 bit left shift.

Many thanks Paul

posted by Paul Lee 30 Jul 2015