Skip to main content
Florian Moser
Senior
October 28, 2019
Solved

How can I prevent the I2C from getting interrupted?

  • October 28, 2019
  • 3 replies
  • 1052 views

There's a sensor applied to the I2C as a slave. Also on this microcontroller there's a communication running on the UART-Interface in blocking mode. If the UART has to transmit a huge amount of data, it seems that the I2C (also blocking mode) can get interrupted, because the I2C Busy Flag is set and I cannot receive data via I2C anymore.

Is there a possibility for the I2C to not get interrupted?

Or am I doing something horribly wrong?

This topic has been closed for replies.
Best answer by Florian Moser

I just wanted to tell you that I've found the problem:

I'm running FreeRTOS and the priority of the UART task was higher than the priority of the I2C task and so the I2C could get interrupted by the UART. Sometimes this interrupt set I2C to busy state.

3 replies

Florian Moser
Florian MoserAuthorBest answer
Senior
October 31, 2019

I just wanted to tell you that I've found the problem:

I'm running FreeRTOS and the priority of the UART task was higher than the priority of the I2C task and so the I2C could get interrupted by the UART. Sometimes this interrupt set I2C to busy state.

Piranha
Principal III
November 2, 2019

I'll remind that changing priorities doesn't solve the problem - it only hides it to come up again in a different situation. The code is incorrect and must be fixed!

Florian Moser
Senior
November 4, 2019

Ok, so what's the actual problem? Why could the I2C get interrupted nevertheless? The UART and the I2C task have the same priority now, so they can't interrupt each other.