cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong Data send after correct Addr with I2C

uli stone
Associate II

0690X000006DTALQA4.png0690X000006DTAGQA4.pngHi,

I'm still having trouble with my I2C communication.

I'm using the Bus as Master, at the moment without any Slave.

After sending the Device Addr, which is transmitted correctly to the ouput (checked with logic analyser) I send data which is then put to the output wrong. When sending 0x0F I get with the logic analyser 0x1E on the Data line.

For the I2C communicatoin I'm using a exit counter to leave the otherwise endless while-loops.

	I2C2_St();
	I2C2_Ad(0x42);
	I2C2_Wr(0x0F);
	I2C2_St();
	I2C2_Ad(0x43);
	I2C2_R(1);
	I2C2_Sp();

Can someone help me how to fix this?

Thank you very much

6 REPLIES 6
S.Ma
Principal

Your capture doesn't show the first start bit. the timeframe is too zoomed.

I see only a start bit at the mini green disk.

Logic analyser should be used AFTER a check of I2C lines by oscilloscope.

Maybe toggle a GPIO at the beginning of the I2C sequence to trigger on it with oscilloscope.

uli stone
Associate II

0690X000006DTB4QAO.pngHi,

added the full waveform:

Image is not available

I hope this helps?

uli stone
Associate II

I removed the for-dealys and the exit-counter and it is working now.

The problem is now, when Address(write) and Register Address and then Slave-Read Address is transmitted, the master (STM32F4) stopps the SCL Signal. How can I "activate" the clock signal so that the slave can transmitt the data to the master?

Following data is send: 0x42+0x01 then 0x43 and this should be followed with data from the slave.

0690X000006DTEmQAO.png

S.Ma
Principal

You are missing a restart.

Your oscilloscope seems wrong, it's MSB bit first 0x01 shows up as 0x80.

S-42a-01a-S-43a-xxa-xxn-P

uli stone
Associate II

Hi,

thank you for your reply. Please notice that the 0x01 bit you mentioned is the 7th bit of the address (then the 0x01 follows correctly)!

The sensor I'm using is a special sensor which doesn't use directly I2C. The only problem I'm facing, that the STM32F4 doesn't holds up the communication after the 0x43 address. How can I do that?

thank you

uli stone
Associate II

When I add a stop-start condition, the stm32f4 does only send: S-42a-01a-S and th0690X000006DUzQQAW.pnge second address and register address is lost.