i2c_t3

Status
Not open for further replies.

dk23

Member
I wanted to use i2c_t3 in a project but was having problems. So I tried one the the examples from github and get the same errors:

Code:
#include <Arduino.h>
#include <i2c_t3.h>

// Function prototypes
void print_scan_status(uint8_t target, uint8_t all);

uint8_t found, target, all;

void setup()
{
    pinMode(LED_BUILTIN,OUTPUT);    // LED
    pinMode(12,INPUT_PULLUP);       // pull pin 12 low to show ACK only results
    pinMode(11,INPUT_PULLUP);       // pull pin 11 low for a more verbose result (shows both ACK and NACK)

    // Setup for Master mode, pins 18/19, external pullups, 400kHz, 10ms default timeout
    Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
    Wire.setDefaultTimeout(10000); // 10ms

    Serial.begin(115200);
}

void loop()
{
    // Scan I2C addresses
    //
    if(digitalRead(12) == LOW || digitalRead(11) == LOW)
    {
        all = (digitalRead(11) == LOW);
        found = 0;
        
        Serial.print("---------------------------------------------------\n");
        Serial.print("Starting scan...\n");
        digitalWrite(LED_BUILTIN,HIGH); // LED on
        for(target = 1; target <= 0x7F; target++) // sweep addr, skip general call
        {
            Wire.beginTransmission(target);       // slave addr
            Wire.endTransmission();               // no data, just addr
            print_scan_status(target, all);
        }
        digitalWrite(LED_BUILTIN,LOW); // LED off

        if(!found) Serial.print("No devices found.\n");
        
        delay(500); // delay to space out tests
    }
}

//
// print scan status
//
void print_scan_status(uint8_t target, uint8_t all)
{
    switch(Wire.status())
    {
    case I2C_WAITING:  
        Serial.printf("Addr: 0x%02X ACK\n", target);
        found = 1;
        break;
    case I2C_ADDR_NAK: 
        if(all) Serial.printf("Addr: 0x%02X\n", target); 
        break;
    default:
        break;
    }
}

Errors:
> Executing task in folder I2C Testing: platformio run <

Processing teensy41 (platform: teensy; board: teensy41; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html
PLATFORM: Teensy (4.11.1) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy 1.153.0 (1.53)
- toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 89 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <i2c_t3>
Building in release mode
Compiling .pio/build/teensy41/src/main.cpp.o
Compiling .pio/build/teensy41/lib4cf/i2c_t3/i2c_t3.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/AudioStream.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/Blink.cc.o
Compiling .pio/build/teensy41/FrameworkArduino/DMAChannel.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/EventResponder.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial1.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial2.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial3.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial4.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial5.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:16:5: error: 'Wire' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
^
src/main.cpp:16:16: error: 'I2C_MASTER' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
^
src/main.cpp:16:34: error: 'I2C_PINS_18_19' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
^
src/main.cpp:16:50: error: 'I2C_PULLUP_EXT' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
^
src/main.cpp: In function 'void loop()':
src/main.cpp:36:13: error: 'Wire' was not declared in this scope
Wire.beginTransmission(target); // slave addr
^
src/main.cpp: In function 'void print_scan_status(uint8_t, uint8_t)':
src/main.cpp:53:12: error: 'Wire' was not declared in this scope
switch(Wire.status())
^
src/main.cpp:55:10: error: 'I2C_WAITING' was not declared in this scope
case I2C_WAITING:
^
src/main.cpp:59:10: error: 'I2C_ADDR_NAK' was not declared in this scope
case I2C_ADDR_NAK:
^
Archiving .pio/build/teensy41/lib4cf/libi2c_t3.a
*** [.pio/build/teensy41/src/main.cpp.o] Error 1
Indexing .pio/build/teensy41/lib4cf/libi2c_t3.a
==================================================== [FAILED] Took 0.66 seconds ====================================================
The terminal process "platformio 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

platformio.ini
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino

monitor_speed = 115200
monitor_port = /dev/ttyACM0


i2c_t3 is being compiled for reasons I don't understand errors related to i2c_t3 occur.

Thanks for the help
 
Thanks,

I should have read the thread on i2c_t3.

Any interest in Teensy 4.x support?
Any one working on it?
I'm just starting to use I2C, would like to understand how to use the I2C 1 and 2 on the Teensy 4.x.
Time for research
 
I don't know about i2c_t3, but you can use all three I2C ports with the official Wire.h package. Just use Wire1 or Wire2 instead of Wire.
 
Status
Not open for further replies.
Back
Top