Forum: µC & Digital Electronics AVR USI TWI master/slave config

von Christoph L. (lehrlii)

Rate this post
not useful
Hi folks,

I'm currently developing a sensor framework based on the TWI bus and I 
use ATtiny85's as sensor nodes.
I want them to be able to communicate as TWI master, therefore I wanted 
to implement the USI in TWI mode with Timer0 as clock.

So my questions are:
1. Do I have to use OCR0A or OCR0A?
2. When using Timer0, do I have to generate the clock manually or is it 
done by the HW?
3. For bus arbitration I would need to detect if the bus is in use. Is 
there a efficient way the detect stop conditions?

Unfortunately not even AVR believes in the USI interface and the whole 
application notes depend on polling and the ATtiny85's datasheet is very 
vague on this topic.

Thanks in advance.

von Hermann (Guest)

Rate this post
not useful
You intend to make the I2C-communication by yourself? In this connection 
I can't help.
I use Bascom and there is a library for master and slave which use the 
USI-HW. I suppose a simular library is available in C. So you have 
nothing to do with bits, clock and timer.
This is quite simple. To practice I have made a master which reads and 
writes an EEPROM. And then I made a slave which emulates this EEPROM. 
The only problem: the slave library costs about 14€ for all SW and HW 
If you are interested I can post the short source code.


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.