steved wrote:On a quick look, the code looks sensible (and, yes, strip the code down to the minimum which shows the problem).
Two hardware things to check:
1. Do you have pullups on the I2C lines? (Typically in the region of 2K2 to 4K7; higher should work if lines are short and speed is low)
2. Are other pins assigned to the same I2C functions (perhaps in the board file)?
Does the problem arise on the first attempt to communicate with the EEPROM?
You might need to put a scope on the lines to see what's going on.
1. I used 10K, I tried 4.7K but it doesn't work as well.
2. I don't think so cause my code use OLIMEX_STM32_P103 board.c for STM32F103C8T6 chinese module.
Interesting that the code didn't hang for 1st time communication but 2nd time did.
I used logic analyzer but couldn't see any I2C signal sent out, check my screenshot below. It works fine on I2C on Arduino.