TWI questions on MegaAVR

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

Hi all, I have the following questions on TWI .

1) I would like to confirm that my understanding of the datasheet (specifically Mega88) is correct. From my reading it seems that using the TWI hardware in master mode - that there is no interrupt and no status in the TWSR register after sending a TWI stop condition. This belief is confirmed by the fact that the TWSTO bit is the only one in the TWCR register that clears itself. For instance TWSTA has to be cleared manually.

2) Following from point 1 above. Because there is no interrupt after a stop condition on TWI, it would seem that the procedure to address a number of TWI slaves from the master in sequence, is the use a repeated start after addressing a slave. Using a new slave address to address the next slave. If one is implementing a totally interrupt driven driver for the master - using repeated start seems to be the mechanism to use, for streaming packets on the TWI bus?

Regards,
Johan Hartman

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

Hi Johan,

1: there's no meaning for an interrupt after a stop if you initiated it. If you have anything to do after the stop, you can do it immediately after sending it. For the start and most other commands, you need to know when they succeeded or failed. If the line or the slave are busy, it may take some time before the start or data are really sent on the line. And you want the interrupt to occur at that time only.

2: yes, and this is also the way to go if you don't use interrupts. You could also send a stop followed by a start but if there's another master on the bus, it can grab the line before your start.

David Bourgeois

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

Thanks David, It always helps to put that nagging feeling to rest.

Johan Hartman