USI as I2C in Attiny85 or any TINY example code?

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

I am trying to use Attiny85 as I2C master. I downloaded the code from Atmel application notes but it didn't work.

Looks like the code from the application notes is outdated for two files

#include
#include

are not found. After change it to

#include

"__delay_cycles" not not defined. I read through previous threads on this and it is said I will need "intrinsics.h" for its definition, which I could not anywhere.

Does anyone has a working code for USI in the TINY family?

Thanks

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

Which compiler. The Atmel sample code is usually for IAR.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

You use AVR310 for a USI Master I2C.

Most Atmel app notes are written for IAR.
The smaller app notes will compile with the free IAR KickStart edition. Some of the app notes are 'out of date' for the current IAR. Some minor changes may be needed.

It is pretty straightforward to port to avr-gcc or CodeVision or ImageCraft. Ask if you want some help.

You can use any bit-bang I2C Master code on a Tiny. Quite honestly, this is easier than using the USI.

Note that AVR312 (USI Slave I2C) does not work. You need the corrected version by Don Blake.

David.

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

Never heard of IAR before, Atmel must have/had a close relationship with it.

In this case, it is not so "straightforward" as the header files are not found in AVR Studio 4.

Now I guess Avr Studio 4 is the official compiler/IDE, the application notes should have been updated to accommodate that.

I don't need the Slave I2C, I just need the master to work. Where can I find a big-bang I2C master code? I don't want to deal with low level I2C interface like "start condition" and etc.

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

clearsky1494 wrote:
In this case, it is not so "straightforward" as the header files are not found in AVR Studio 4.

Oh come on ... Yes, the app note doesn't spoon feed you. But looking over the code you should get the gist in a few minutes, and be able to rewrite it for your own compiler. This, of course, requires you know your own compiler.

Do you know your own compiler?

If not, start there, and stop whining about a few missing headers.

Stealing Proteus doesn't make you an engineer.

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

"know your own compiler" is not the answer to everything.

What is the point of putting up some old code that doesn't work in the app note and ask people to rewrite it and "know your own compiler"?

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

I think you have a very good point.

I have no problem with Atmel 'preferring' IAR over any other compiler. There is a free KickStart evaluation version.

I do think that they could make sure that their app notes (and code) are up to date. With bugs fixed.

As I said in a previous post, you can just run a sed script to convert most code to avr-gcc (or other Compiler). Or simply use the IAR compiler !!

Fortunately the Xmega app notes are immediately compilable by avr-gcc.

Most things require some effort on the part of the User. I expect that even Arnold has to read the PDF and HTML before using any example code. I certainly need to.

If there is some paragraph in the PDF or HTML that you do not understand, quote the page / paragraph number.

David.

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

david.prentice wrote:
I expect that even Arnold has to read the PDF and HTML before using any example code.
See my signature. I practice what I preach.

Stealing Proteus doesn't make you an engineer.