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

Conflicts with UART and I2C

Hello,

I develop a system which contains a real time clock via i2C and is controlled by the computer via the RS232 protocol.

In order to develop the I2c part i take the lower functions of the application notes cygnal_i2c.zip and receive the information from the uart via interruption.

Each technologie work properly when they are separate but when I want to execute them in the same project i have a conflict: if i receive an event from the uart in the same time as the i2c wait for an acknowledgment from the slave part, the program stack.

Have anybody an idea on the subject?

Parents
  • When an interrupt happens while bit banging is is progress the timing window changes because the ISR must be processed. Your problem most likely is that your UART ISR does too much. Try just storing the received byte in a ring buffer in the ISR and do the rest of the processing in main.

    ISR = Sweet when short

    Erik

Reply
  • When an interrupt happens while bit banging is is progress the timing window changes because the ISR must be processed. Your problem most likely is that your UART ISR does too much. Try just storing the received byte in a ring buffer in the ISR and do the rest of the processing in main.

    ISR = Sweet when short

    Erik

Children
  • Thank you i think i will do so....

  • To keep i2c communication run properly, that is the timing and the sequence, the operation can not be interrupted. For example, being interrupted while you are waiting for the ACK. You would miss the ACK while excuting the uart_isr. The response time for the ACK is in the microsecond range, but excuting isr would take at least ten times of that. So, no matter how short the isr is, you would still mess up the i2c operation. On the other hand, if you postpone the uart operation to excute the i2c, you would not miss the data on the uart bus if you come back on time before the next byte overwrite it. The interbyte time with 9600 baud rate is about 1.2ms, so you would have a full milisecond to excute i2c bus.

    But generally speaking, this is the truth:
    isr = sweet if short.