AVR USI TWI master/slave config

OP #5237623
Rate this post
• ▲ useful
▼ 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.
Guest #5238039
Rate this post
• ▲ useful
▼ 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 
solutions.
If you are interested I can post the short source code.

Reply

A question of your own? This thread is over 8 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.