Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: Teensy 3.2 and i2c_t3.h error compile

  1. #1
    Junior Member
    Join Date
    Aug 2021
    Posts
    9

    Teensy 3.2 and i2c_t3.h error compile

    Hello
    I am new to teensy ,first I use atmel studio then arduino then stm32 and now teensy.
    I am using i2c with oled display sh1106 and I need to push this display at 2mhz because I need it for car instrument.
    I have use this display before with stm32 and hal and is very fast.
    So for teensy I would like to use i2c_t3 lib but I am geting this errors
    with arduino library work but is too slow.

    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o: In function `i2c0_isr':
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.cpp:912: multiple definition of `i2c0_isr'
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.cpp:1132: first defined here
    c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:133: multiple definition of `i2c1_isr'
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:133: multiple definition of `Wire1'
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here
    c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Warning: size of symbol `Wire1' changed from 20 in C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o: In function `Print::availableForWrite()':
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:133: multiple definition of `Wire'
    C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o:C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3/i2c_t3.h:883: first defined here
    c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Warning: size of symbol `Wire' changed from 20 in C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\PETROS~1\AppData\Local\Temp\arduino_build _117116\libraries\Wire\WireKinetis.cpp.o
    collect2.exe: error: ld returned 1 exit status
    Error compiling for board Teensy 3.2 / 3.1.

    my code until now

    Code:
    // #include <Arduino.h>
    #include <U8g2lib.h>
    //#include <Wire.h>
    #include <i2c_t3.h>
    U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
    
    int i = 0 ;
    
    void setup() {
    Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
      Wire.setDefaultTimeout(200000); // 200ms
      
    // Wire.setClock(1000000);
     //Wire.begin(); 
    delay (1000);
    u8g2.begin();
    delay (1000);
    u8g2.clearBuffer();
    u8g2.setCursor(1, 35);
    //u8g2.setFont(u8g2_font_profont22_mf);
    u8g2.setFont(u8g2_font_10x20_mf);
    }
    
    void loop() {
    for (i =1; i < 500; i++) {
      u8g2.setCursor(10, 35);
    u8g2.print(i);
    u8g2.print("  ");
    u8g2.sendBuffer();
    }
      // put your main code here, to run repeatedly:
    
    }
    Last edited by petros047; 08-16-2021 at 12:46 AM.

  2. #2
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    well finally the problem is with u8g2 lib
    I change the U8x8lib.cpp file from :
    Code:
    #include "U8x8lib.h"
    #ifdef U8X8_HAVE_HW_SPI
    #include <SPI.h>
    #endif 
    #ifdef U8X8_HAVE_HW_I2C
    #include <Wire.h>
    #endif
    to
    Code:
    #include "U8x8lib.h"
    #ifdef U8X8_HAVE_HW_SPI
    #include <SPI.h>
    #endif 
    #ifdef U8X8_HAVE_HW_I2C
    #include <i2c_t3.h>
    #endif
    Now the program compile with no errors but still my speed is 352khz according to my oscilloscope

  3. #3
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    Also the wire.set.clock doesnt speed my i2c clock
    I have try it

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,271
    Seems .setClock() is supported.

    Try putting the desired clock speed in the .begin() instead:

    >> Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);

  5. #5
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    Can you post example please?

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,271
    Not seeing posted working code, or expected/desired speed that will work with device at hand.

    posted example from p#1 code in p#4 - if that is what is working - just pick a valid and proper speed instead of 400000

    For other options on the .begin search in for parameter set to use : {local install}\arduino-1.8.15\hardware\teensy\avr\libraries\i2c_t3\i2c_t3 .h
    > that file lists supported speeds and multiple .begin() prototypes that should work.

  7. #7
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    This is a working code
    Code:
    #include <i2c_t3.h>
    U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
    
    int i = 0 ;
    
    void setup() {
    Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
      Wire.setDefaultTimeout(200000); // 200ms
      
    // Wire.setClock(1000000);
     //Wire.begin(); 
    delay (1000);
    u8g2.begin();
    delay (1000);
    u8g2.clearBuffer();
    u8g2.setCursor(1, 35);
    //u8g2.setFont(u8g2_font_profont22_mf);
    u8g2.setFont(u8g2_font_10x20_mf);
    }
    
    void loop() {
    for (i =1; i < 500; i++) {
      u8g2.setCursor(10, 35);
    u8g2.print(i);
    u8g2.print("  ");
    u8g2.sendBuffer();
    }
      // put your main code here, to run repeatedly:
    
    }
    The desired speed is 2mhz but as I read in manual for teensy 3,2 can go up to 1mhz so probably 1mhz is desired
    Thank you I will read the file as you mention

  8. #8
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,365
    Just a little point, but can be vital (spacecraft have been lost for carelessness with units!)

    m = milli
    M = mega
    Hz = hertz (not hz, h means hecto, z means zepto, so hz means 10^-19)

    You mean 2MHz, 1MHz....

  9. #9
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    Yes you are right sorry for typing mistake I mean 1MHz

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,421
    Quote Originally Posted by MarkT View Post
    Just a little point, but can be vital (spacecraft have been lost for carelessness with units!)
    Wasn't that because they did'nt use the worldwide metric standard and used something strange instead? Something with Newton ./. "points of force"

    Btw, Heinrich Hertz was a scientist, and the unit was named after him. So, it's Hertz, not hertz. sorry for nit-picking
    Last edited by Frank B; 08-16-2021 at 12:57 PM.

  11. #11
    Junior Member
    Join Date
    Aug 2021
    Posts
    9
    Well Finally I found the problem.
    U8g2 use defined clock so there doesnt matter what are you set in setup
    So first I have to set the bus for u8g2 and after that the changes in i2c library take effect.
    I read 2MHz to my oscilloscope with 470 ohm resistor and overclock to 120MHz to teensy 3.2
    Also I have change and the U8x8lib.cpp to
    Code:
    include "U8x8lib.h"
    #ifdef U8X8_HAVE_HW_SPI
    #include <SPI.h>
    #endif 
    #ifdef U8X8_HAVE_HW_I2C
    #include <i2c_t3.h>
    #endif
    and the working code
    Code:
    #include <i2c_t3.h>
    #include <U8g2lib.h>
    
    U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
    
    int i = 0 ;
    
    void setup() {
     Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 3000000);
     Wire.setDefaultTimeout(200000); // 200ms
    
    
    delay (100);
    u8g2.setBusClock(3000000);
    u8g2.begin();
    delay (100);
    u8g2.clearBuffer();
    u8g2.setCursor(1, 35);
    //u8g2.setFont(u8g2_font_profont22_mf);
    u8g2.setFont(u8g2_font_10x20_mf);
    }
    
    void loop() {
    for (i =1; i < 500; i++) {
      u8g2.setCursor(10, 35);
    u8g2.print(i);
    u8g2.print("  ");
    u8g2.sendBuffer();
    }
      // put your main code here, to run repeatedly:
    
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •