We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Not an ARM Guy But for I2C (and SMBus) it AAAAAAAW
so the battery is 0x16 b00010110 AKA 0x0B b00001011
So using the Address a 0x0B you may need to shift left one to skip the Read / Write Bit. ( Depending one what the Hardware wants)
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
I can not help past this point. If the Libraries do not suit your needs you can code it your self. If the libraries are supported and do not work, check for updates, look at the source code if it is available, or contact the Manufacturer. Sorry I can not help further.