I2C_Anything icon indicating copy to clipboard operation
I2C_Anything copied to clipboard

ATtiny84

Open classic-audio opened this issue 6 years ago • 4 comments

I have used your clever I2C_Anything for 2 Arduino Uno. It work fantastic / easy. I would like to use it in ATtiny 84 or 85 but I cant really get it to work. A little would be great.

classic-audio avatar Jun 21 '18 19:06 classic-audio

Can you give more details? What happened?

nickgammon avatar Jul 27 '18 21:07 nickgammon

Hello

I'll also like to use your library with an ATtiny85, but can't compile on Arduino IDE 1.8.0

Please note that It compiles for the UNO

When I try to compile for the ATtiny85, I receive errors like below

Thanks

/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_init':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:76:16: error: 'SDA' undeclared (first use in this function)
   digitalWrite(SDA, 1);
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:76:16: note: each undeclared identifier is reported only once for each function it appears in
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:77:16: error: 'SCL' undeclared (first use in this function)
   digitalWrite(SCL, 1);
                ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:80:7: error: 'TWSR' undeclared (first use in this function)
   cbi(TWSR, TWPS0);
       ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:80:3: note: in expansion of macro 'cbi'
   cbi(TWSR, TWPS0);
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:80:13: error: 'TWPS0' undeclared (first use in this function)
   cbi(TWSR, TWPS0);
             ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:80:3: note: in expansion of macro 'cbi'
   cbi(TWSR, TWPS0);
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:81:13: error: 'TWPS1' undeclared (first use in this function)
   cbi(TWSR, TWPS1);
             ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:81:3: note: in expansion of macro 'cbi'
   cbi(TWSR, TWPS1);
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:82:3: error: 'TWBR' undeclared (first use in this function)
   TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:90:3: error: 'TWCR' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
   ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:90:14: error: 'TWEN' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
              ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:90:26: error: 'TWIE' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
                          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:90:38: error: 'TWEA' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
                                      ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_disable':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:102:3: error: 'TWCR' undeclared (first use in this function)
   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
   ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:102:17: error: 'TWEN' undeclared (first use in this function)
   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
                 ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:102:29: error: 'TWIE' undeclared (first use in this function)
   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
                             ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:102:41: error: 'TWEA' undeclared (first use in this function)
   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
                                         ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:105:16: error: 'SDA' undeclared (first use in this function)
   digitalWrite(SDA, 0);
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:106:16: error: 'SCL' undeclared (first use in this function)
   digitalWrite(SCL, 0);
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_setAddress':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:118:3: error: 'TWAR' undeclared (first use in this function)
   TWAR = address << 1;
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_setFrequency':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:129:3: error: 'TWBR' undeclared (first use in this function)
   TWBR = ((F_CPU / frequency) - 16) / 2;
   ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_readFrom':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:187:7: error: 'TWDR' undeclared (first use in this function)
       TWDR = twi_slarw;
       ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:188:13: error: 'TWCR' undeclared (first use in this function)
     } while(TWCR & _BV(TWWC));
             ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:188:24: error: 'TWWC' undeclared (first use in this function)
     } while(TWCR & _BV(TWWC));
                        ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:189:16: error: 'TWINT' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:189:29: error: 'TWEA' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                             ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:189:41: error: 'TWEN' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                                         ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:189:53: error: 'TWIE' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                                                     ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:193:65: error: 'TWSTA' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
                                                                 ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_writeTo':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:269:7: error: 'TWDR' undeclared (first use in this function)
       TWDR = twi_slarw;    
       ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:270:13: error: 'TWCR' undeclared (first use in this function)
     } while(TWCR & _BV(TWWC));
             ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:270:24: error: 'TWWC' undeclared (first use in this function)
     } while(TWCR & _BV(TWWC));
                        ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:271:16: error: 'TWINT' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:271:29: error: 'TWEA' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                             ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:271:41: error: 'TWEN' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                                         ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:271:53: error: 'TWIE' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
                                                     ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:275:65: error: 'TWSTA' undeclared (first use in this function)
     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs
                                                                 ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_reply':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:357:5: error: 'TWCR' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
     ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:357:16: error: 'TWEN' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
                ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:357:28: error: 'TWIE' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
                            ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:357:40: error: 'TWINT' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
                                        ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:357:53: error: 'TWEA' undeclared (first use in this function)
     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
                                                     ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_stop':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:3: error: 'TWCR' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
   ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:14: error: 'TWEN' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
              ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:26: error: 'TWIE' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
                          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:38: error: 'TWEA' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
                                      ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:50: error: 'TWINT' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
                                                  ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:372:63: error: 'TWSTO' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
                                                               ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'twi_releaseBus':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:393:3: error: 'TWCR' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
   ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:393:14: error: 'TWEN' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
              ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:393:26: error: 'TWIE' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
                          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:393:38: error: 'TWEA' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
                                      ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:393:50: error: 'TWINT' undeclared (first use in this function)
   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
                                                  ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/compat/twi.h:36:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:27:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c: In function 'TWI_vect':
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWSR' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWS7' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWS6' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWS5' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWS4' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:401:10: error: 'TWS3' undeclared (first use in this function)
   switch(TW_STATUS){
          ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:406:7: error: 'TWDR' undeclared (first use in this function)
       TWDR = twi_slarw;
       ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:426:4: error: 'TWCR' undeclared (first use in this function)
    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
    ^
In file included from /home/mauricio/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:25:
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:426:15: error: 'TWINT' undeclared (first use in this function)
    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
               ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:426:28: error: 'TWSTA' undeclared (first use in this function)
    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
                            ^
/home/mauricio/.arduino15/packages/arduino/hardware/avr/1.6.18/libraries/Wire/src/utility/twi.c:426:40: error: 'TWEN' undeclared (first use in this function)
    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
                                        ^
exit status 1
Error compilación en tarjeta ATtiny25/45/85.

gusantor avatar Jan 19 '19 15:01 gusantor

The ATtiny85 has different I2C hardware than the Atmega328. The problem here is not the I2C_Anything library but the fact that you can't use the Wire library on that chip.

Try finding a library for the Attiny, for example here although I didn't test that.

nickgammon avatar Feb 04 '19 20:02 nickgammon

Thank you !

Hopefully I'll give it a try

gusantor avatar Feb 04 '19 20:02 gusantor