cancel
Showing results for 
Search instead for 
Did you mean: 

I2c peripheral adding address byte ?

joemccarr
Senior
Posted on December 31, 2016 at 00:25

Using I2C peripheral on F0 micro.  When I restart the I2C bus it sends the slave address plus an extra byte then my data, after that first transmission it doesnt send the extra byte, just the after the first Restart. Problem is now my data array is off by one byte. I can not seem to be able to control the master from sending this 'extra' byte.

For example ...

First I send 06,00,00 which sets the direction of the two 8 bit registers. This works as expected.

On the LA I get:

0x40 0x06 0x00 0x00 ACK   (which is what is expected)

(0x40 is slave, 0x06 is direction reg address, and the 0x00  0x00  configures the pins as output.

The next three btyes are the starting address and two data bytes 0x02, 0xff, 0x50

On the LA I get I get:

0x40 0x02 0x02 0xff ACK     (data byte 0x02 is added by the i2c peripheral)

This only happens on the first transmission after restarting, after that only my data is sent but now because of the

extra byte I am off by one byte.
2 REPLIES 2
joemccarr
Senior
Posted on December 31, 2016 at 00:41

In the above the ack is after each byte transmitted not just at the end.

Seb
ST Employee
Posted on December 31, 2016 at 07:06

It can sometime be easier to start with GPIO+SW bit banging. Some sample code here:

https://community.st.com/0D50X00009XkW1mSAF

If 'restart' means 'repeated start' condition, then it is usually used to switch from write to read a chosen slave device.

Hope this helps a bit, such as accessing a EEPROM memory.

Good luck!