This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SMBUS issues

Hello everyone,
I'm actually working on the MCBSTM32E eval board which is composed of the STM32F103ZE. It is connected to a smart battery component (BQ2040 from TI). The bus between them is SMBUS, so I connected the BQ to I2C1. I have some questions about this latter. I can easily communicate with the BQ BUT :
- First : my own address is always taken by the soft as a 10-bit one instead of a 7-bit (it means that I have to put 0x03 if I want my I2C address to be 0x01) and it is the same when I want to write something in the BQ whose address is 0x0B I have to put 0x17. It seems that I have to add one extra bit (1). How can I change that ?
- Second : the example given in µvision directories (ST Examples) uses while loop to wait for an event (as required in . But when an error occurs (like a missing ack), it means that I'm stuck in the loop forever. How could I handle it ? I think when an error occur I should reset the I2C and recall the function, but I have no idea on how to recall it.
- Third : I don't know why but the BQ sends me an Ack even after the Data Byte H while it should send nothing or a Nack which would mean that I can generate my stop.
I hope my post is not that confusing cause I tried to make as clear as I can.
Thanks in advance,
Regards
Gary

Parents
  • Thank you for your answer but I knew that. The thing is that I use the ST FWLib and so in the function
    "I2C_Send7bitAddress(I2C1, 0x17, I2C_Direction_Transmitter);"
    I expected that the address did not need the extra bit as we notify it with the I2C_Direction. It is just that I dont find it really clear. Moreover the function is named Send7bitAddress so it was clear (for me) that we did not have to add the R/W bit.
    The thing that bothers me most is the loop used to wait for an event. I dont know, even with interrupt, how I can recall the function if an Ack miss happens.
    Regards

Reply
  • Thank you for your answer but I knew that. The thing is that I use the ST FWLib and so in the function
    "I2C_Send7bitAddress(I2C1, 0x17, I2C_Direction_Transmitter);"
    I expected that the address did not need the extra bit as we notify it with the I2C_Direction. It is just that I dont find it really clear. Moreover the function is named Send7bitAddress so it was clear (for me) that we did not have to add the R/W bit.
    The thing that bothers me most is the loop used to wait for an event. I dont know, even with interrupt, how I can recall the function if an Ack miss happens.
    Regards

Children