Atmega644 as i2c slave always does clock stretching

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We run two Atmega644 in our device.

One runs at 20MHz external crystal, it's an ATMEGA644 20AU.

The other runs at 8MHz internal oscillator, an ATMEGA644V 10AU.

The latter one ALWAYS does ~12 µs SCL stretching at the end on every byte received. The former one does not have this problem.

Any hint as to why? It is not much of a problem, more an annoyance.

Regards,

/Bo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MrMayhem wrote:

Any hint as to why? It is not much of a problem, more an annoyance.

The common cause is the slave code has too much code to run in time so it stretches the clock. You can try finding a more efficent way to write the code. Or try different optimization settings. Or try a slower I2C clock speed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The slave need time to execute the I2C interrupt handler.
Since there exist no I2C buffer, it must stretch the SCL until ready to receive the next byte, otherwise data was lost.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But why does not the one on external crystal show this behaviour?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's not about external/internal.
The external crystal is more then twice as fast, so that AVR gets the work done a lot faster.