Wrong Data send after correct Addr with I2C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-10 7:37 AM
Hi,
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-10 8:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-10 8:25 AM
Hi,
added the full waveform:
Image is not available
I hope this helps?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-10 5:22 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-10 6:14 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-11 2:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-11 9:19 AM
When I add a stop-start condition, the stm32f4 does only send: S-42a-01a-S and the second address and register address is lost.
