ATtiny2313 defs not being included

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

I'm trying to compile a sample I2C slave app using the tn2323 (defined in the project), but somehow the USI related registers (TWAR, TWCR, etc.) aren't being defined/included. I thought this was supposed to be automatic in AVR Studio once the particular part was selected for the project.

Is there something else that needs to be done ?

I've located the [ tn2313def.inc ] file which I suppose could be used, but I have no idea how to integrate this into what is now an all C++ project.

I even have the XML def file, but I understand that the XML converter utility is now defunct.

Ray

Attachment(s): 

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

Quote:
I thought this was supposed to be automatic in AVR Studio once the particular part was selected for the project.

Is there something else that needs to be done ?


Yes, start each of your source files with

#include 

EDIT: Which you seem to be doing...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I guessing there's more problems with this code than just the 2313 defs, but when you compile do you get errors about missing USI defs ? If not, that would indicate a library problem on my end.

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

"Your" code is written for IAR compiler - so what compiler are you using then and what the AVR Studio has to do with all this stuff?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

Yes, I'm converting it to AVR Studio/GCC, else I would not have posted in this forum.

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

? Would someone try to build this tiny project and let me know if you are get undefined USI registers ?

Thanks

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

pascor wrote:
I'm trying to compile a sample I2C slave app using the tn2323 (defined in the project), but somehow the USI related registers (TWAR, TWCR, etc.) aren't being defined/included. I thought this was supposed to be automatic in AVR Studio once the particular part was selected for the project.

Is there something else that needs to be done ?

I've located the [ tn2313def.inc ] file which I suppose could be used, but I have no idea how to integrate this into what is now an all C++ project.

I even have the XML def file, but I understand that the XML converter utility is now defunct.

Ray


I am not too sure what a 'tn2323' is.

The ATtiny2313 possesses a USI peripheral. It does not contain a TWI peripheral.

You need to use the AVR312 app note as modified by Don Blake.

In common with most 'I2C Slave' questions, you must decide what and how your Slave will behave.

The Atmel app notes are perfectly adequate, but do not do anything useful. Life is easier if you say that you want to emulate a particular chip with possible modifications. At least this means that others know what you want to do !!

David.

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

Yes. an ATtiny2313. Various files and tools use all kinds of aliases like this.

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

Apparently, these are convenience definitions standard in the IAR Embedded Workbench for Atmel AVR.

Does anyone happen to have the definitions file for the 2313 in IAR ?

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

Quote:
let me know if you are get undefined USI registers ?
?? I just built the code as above and there is nothing about USI in the code that I can see. All errors refer to the use of TWI registers which are non existing in the Tiny 2313.

Is there another set of files you are working with?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I've learned that the problem that I'm having is due the 2 different architectures for I2C protocol implementation using different AVRs. Meaning, those that have an "address mask register" and those that don't. As an experiment, I changed the target to an ATMega16 which, when compiled produced only 2 minor errors.

The differences due to the code being written for the IAR compiler are trivial and easy to port.

Now I understand the basic difference between app notes AVR311 (AVRs that have a TWI module) and AVR312 (those that have a USI module). Just as I2C protocol implementation uses a particular subset of the TWI module so does I2C implementation using a subset of the USI hardware module. It's unfortunate that the USI module doesn't have the TWI module as its core. Maybe they are incompatible.

Thanks for the help.

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

I just figured out why I got confused in the first place. Don Blake named his AVR311 I2C code "UsiTwiSlave.c/.h". These are misnamed. There's no TWI hardware in the 2313, for example. The USI has "Two Wire Interface" registers, but there's nothing named "TWI" in the chip. That's Don Blake's bad for misleading everyone. The files should have been named "UsiI2cSlave.c/.h". These are in contrast to, say, a three-wire SPI protocol implementation where appropriate file names would be "UsiSpiSlave.c/.h".

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

Quote:
It's unfortunate that the USI module doesn't have the TWI module as its core.
But that's the foundation of a Universal Serial Interface, it's not tied up to any particular peripheral type.

It can be I2C/TWI, SPI, USART, something else...It's only just above bit banging.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
Don Blake named his AVR311 I2C code "UsiTwiSlave.c/.h".

I suppose you are referring to AVR312 in the same way that your 'tn2323' refers to tn2313.

We all make typos. We all misunderstand things at times. Life is a lot easier if you make corrections to your posts.

The differences between IAR and any other Compiler are pretty straightforward.
Occasionally avr-gcc adds some superfluous #defines for some special function registers.
No compiler calls a spade a shovel. The USI works in a completely different way to the TWI.

However it is very sensible to use identical high-level APIs. So your main program will call uint8_t i2c_readbuf(uint8_t slave, uint8_t *buf, uint8_t n) or uint8_t i2c_writebuf(uint8_t slave, uint8_t *buf, uint8_t n)
You simply link with a USI or TWI implementation as appropriate for your AVR.

David.

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

Quote:
But that's the foundation of a Universal Serial Interface, it's not tied up to any particular peripheral type.

It can be I2C/TWI, SPI, USART, something else...It's only just above bit banging.

Exactly. I'm just saying that It would have been nice if all this capability could have been created by adding to a TWI core. That would have allowed code compatibility and only needing a single set of drivers. I guess that's too much to ask for. I'm sure Atmel tried this first then had to start a fresh design.

Quote:
We all make typos. We all misunderstand things at times. Life is a lot easier if you make corrections to your posts.

Up to this moment I didn't realize that I had even made a typo. Sorry about that.

Thanks again for your help.