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

Thread: I2C between Teensy 3.6 slave and ARM master

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Posts
    7

    I2C between Teensy 3.6 slave and ARM master

    I need to interface an ARM based microcontroller (STM32F446ZETx) with a Teensy 3.6 via I2C. The ARM controller is to serve as the master, while the Teensy will act as a slave, unifying multiple sensor inputs and passing the data to the master upon request.

    The issue that I have encountered is that I am not quite sure how to initiate a request on the ARM side of things, as the developer of this particular controller is quite sparse on details. The have provided the following, publicly available, code snippet as the sole demo of i2c communication (in this case, to read from an EEPROM):
    Code:
    uint8_t addr = 0b1010000; // 7-bit slave address
    ioctl(I2C_USER_FILENO, IOCTL_CMD_RD, &addr);
    uint8_t toSend[] = { 0xFA }; // command byte (to send). In this case it is the register address to read
    write(I2C_USER_FILENO, (char *)toSend, 1);
    
    // The EEPROM contains an EUI48 MAC address at this location
    uint8_t mac[6];
    read(I2C_USER_FILENO, (char *)mac, 6);
    I have attempted to initiate a request to the Teensy slave by using the address defined on the slave (0x66), but I cannot get the Teensy slave to recognize the request. I believe this has to do with the command byte that the mfrg references in the code above, in which case I have no idea what to do with this, as I have never used a non-Teensy master in I2C. Is there a particular command byte that a Teensy expects before recognizing an I2C request?

    Any advice on this would be appreciated, Thanks!

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    2,996
    have you installed the required resistors for I2C? it wont work without them

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,914
    1: Maybe use an oscilloscope or logic analyzer to watch the SDA & SCL pins.

    2: Perhaps use a Teensy 3.6 instead of that STM32 chip? They you'll have good software support.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,565
    ...and it is an ARM, too

  5. #5
    Junior Member
    Join Date
    Feb 2019
    Posts
    7
    @tonton81
    For Teensy to Teensy, I use external pull up resistors (1kohm was doing ok). I did the same with the STM32, but when I probed just the I2C (with the pull up disconnected), it was holding at 3.3v, so I think the STM32 board has pull up resistors built in, ones that I cannot control at this point...

    @PaulStroffregen
    Thank you, I had completely forgotten about my scope. I scoped it both Teensy to Teensy (where i2c works fine) and STM32 to Teensy (where I2C does not work). From what I can tell, there is either an issue with the STM32 board or the code on the STM32, not with the Teensy.

    2: Perhaps use a Teensy 3.6 instead of that STM32 chip? They you'll have good software support.
    You have NO idea how much I wish I could. We paid thousands of $ for this [STM32 based] system, hoping to speed development, but the OEM has locked down the programming so much that the ability to customize it beyond their original use is virtually non-existant. As there are more components than just a main board, I cannot easily swap in a Teensy. Alas, I wish I would have built the system from the ground up around something like a Teensy, but we THOUGHT that would be the more time intensive option...


    As it stands right now, I am confident in saying that the Teensy is not the problem here. There is something fishy going on with the STM32 main board or its program. I have submitted [another] request to their tech support site and am going to go have a beer before I launch into the mother of all curse rants regarding that manufacturer...

    Thank you guys for your suggestions.

Posting Permissions

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