I2C bus occupied
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have a problem with an I2C communication and want you to ask whether there is a better solution than mine.
I am programming an STM32F103 at the moment. There is one sensor (MPU6050) which is connected via I2C to the STM32. I recognized that if I reset the STM32 a few times, the STM32 gets stuck (or got an timeout error) during the initialization of the I2C. The timeout error was during the wait of the busy flag. So the I2C communication was "occupied". The MPU6050 is the only other I2C device (slave).
In my opinion there is an error, because I was reading a register from the MPU6050 when I reset the STM32. So the MPU6050 never gets the stop condition.
I do not know how to reset the I2C connection, when the bus is "occupied" (by the MPU6050). So my solution would be to do a hardware reset with a transmission gate of the MPU6050. Is there maybe a simpler software solution?
Thanks for the help.
i2c stm32f10x
add a comment |Â
up vote
2
down vote
favorite
I have a problem with an I2C communication and want you to ask whether there is a better solution than mine.
I am programming an STM32F103 at the moment. There is one sensor (MPU6050) which is connected via I2C to the STM32. I recognized that if I reset the STM32 a few times, the STM32 gets stuck (or got an timeout error) during the initialization of the I2C. The timeout error was during the wait of the busy flag. So the I2C communication was "occupied". The MPU6050 is the only other I2C device (slave).
In my opinion there is an error, because I was reading a register from the MPU6050 when I reset the STM32. So the MPU6050 never gets the stop condition.
I do not know how to reset the I2C connection, when the bus is "occupied" (by the MPU6050). So my solution would be to do a hardware reset with a transmission gate of the MPU6050. Is there maybe a simpler software solution?
Thanks for the help.
i2c stm32f10x
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a problem with an I2C communication and want you to ask whether there is a better solution than mine.
I am programming an STM32F103 at the moment. There is one sensor (MPU6050) which is connected via I2C to the STM32. I recognized that if I reset the STM32 a few times, the STM32 gets stuck (or got an timeout error) during the initialization of the I2C. The timeout error was during the wait of the busy flag. So the I2C communication was "occupied". The MPU6050 is the only other I2C device (slave).
In my opinion there is an error, because I was reading a register from the MPU6050 when I reset the STM32. So the MPU6050 never gets the stop condition.
I do not know how to reset the I2C connection, when the bus is "occupied" (by the MPU6050). So my solution would be to do a hardware reset with a transmission gate of the MPU6050. Is there maybe a simpler software solution?
Thanks for the help.
i2c stm32f10x
I have a problem with an I2C communication and want you to ask whether there is a better solution than mine.
I am programming an STM32F103 at the moment. There is one sensor (MPU6050) which is connected via I2C to the STM32. I recognized that if I reset the STM32 a few times, the STM32 gets stuck (or got an timeout error) during the initialization of the I2C. The timeout error was during the wait of the busy flag. So the I2C communication was "occupied". The MPU6050 is the only other I2C device (slave).
In my opinion there is an error, because I was reading a register from the MPU6050 when I reset the STM32. So the MPU6050 never gets the stop condition.
I do not know how to reset the I2C connection, when the bus is "occupied" (by the MPU6050). So my solution would be to do a hardware reset with a transmission gate of the MPU6050. Is there maybe a simpler software solution?
Thanks for the help.
i2c stm32f10x
i2c stm32f10x
edited Aug 19 at 21:55
SamGibson
10.1k41436
10.1k41436
asked Aug 19 at 21:09
Lukas_M94
162
162
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
One general solution to unsticking an I2C bus is to just clock the SCL line for 18 or more cycles. This will clock the rest of the current byte out of the slave, let it see a NACK and then clock out one more byte. However, if the slave is very confused, this may not work. Also, most hardware I2C modules cannot do this so you would need to take control of the I2C lines as GPIOs and clock it manually.
Externally driving a reset line to the slave is the best solution. Also, some slaves can be configured to timeout after a relatively long time (e.g. 250 ms).
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
One general solution to unsticking an I2C bus is to just clock the SCL line for 18 or more cycles. This will clock the rest of the current byte out of the slave, let it see a NACK and then clock out one more byte. However, if the slave is very confused, this may not work. Also, most hardware I2C modules cannot do this so you would need to take control of the I2C lines as GPIOs and clock it manually.
Externally driving a reset line to the slave is the best solution. Also, some slaves can be configured to timeout after a relatively long time (e.g. 250 ms).
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
add a comment |Â
up vote
6
down vote
One general solution to unsticking an I2C bus is to just clock the SCL line for 18 or more cycles. This will clock the rest of the current byte out of the slave, let it see a NACK and then clock out one more byte. However, if the slave is very confused, this may not work. Also, most hardware I2C modules cannot do this so you would need to take control of the I2C lines as GPIOs and clock it manually.
Externally driving a reset line to the slave is the best solution. Also, some slaves can be configured to timeout after a relatively long time (e.g. 250 ms).
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
add a comment |Â
up vote
6
down vote
up vote
6
down vote
One general solution to unsticking an I2C bus is to just clock the SCL line for 18 or more cycles. This will clock the rest of the current byte out of the slave, let it see a NACK and then clock out one more byte. However, if the slave is very confused, this may not work. Also, most hardware I2C modules cannot do this so you would need to take control of the I2C lines as GPIOs and clock it manually.
Externally driving a reset line to the slave is the best solution. Also, some slaves can be configured to timeout after a relatively long time (e.g. 250 ms).
One general solution to unsticking an I2C bus is to just clock the SCL line for 18 or more cycles. This will clock the rest of the current byte out of the slave, let it see a NACK and then clock out one more byte. However, if the slave is very confused, this may not work. Also, most hardware I2C modules cannot do this so you would need to take control of the I2C lines as GPIOs and clock it manually.
Externally driving a reset line to the slave is the best solution. Also, some slaves can be configured to timeout after a relatively long time (e.g. 250 ms).
answered Aug 19 at 21:24
DoxyLover
5,19811221
5,19811221
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
add a comment |Â
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
4
4
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
+1 I believe this issue is documented in an old Philips AppNote, but I can't find it right now. So in case it helps readers, here's a link to Analog Devices AppNote AN-686 which also describes the problem and the approaches you kindly mentioned, for those who want more reading material on the topic.
â SamGibson
Aug 19 at 22:13
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
Thanks. Yeah like in the document at figure 1, I would do a cut of the power line to reset the MPU6050.
â Lukas_M94
Aug 20 at 5:17
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f391839%2fi2c-bus-occupied%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password