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

Thread: I2C on Teensy MicroMod with large writes

  1. #1

    I2C on Teensy MicroMod with large writes

    The basic gist of it is that I've got a 2 megabit EEPROM connected to the MicroMod over I2C. This EEPROM chip has 256 byte pages and I want to read or write whole pages at once. I'm caching pages in RAM in order to be able to minimize writes and only write full pages at once. This project is being ported over from the Arduino Due. On the Due what I did was fork the Wire library and increase the buffer size to 258 so I could send my two command bytes + 256 bytes of data all in a single go. I'd like to not pull the same shenanigans this time around if I can help it. So, I suppose I could send 32 bytes (the buffer size in the Wire library) then wait until they send and send 32 more, etc without any stopping until the full 258 bytes is sent. But, that seems crude. The IMXRT chip is pretty powerful and it seems like I ought to be able to use DMA to trigger a buffer write for my own buffer - set it, forget it. But, the library doesn't seem to support this. It seems like perhaps I could use FlexIO to do an I2C DMA transfer. That seems perhaps a little overly complicated since it appears no one has paved the path for me already (yeah... being lazy...)

    So, what's the best way to send 258 bytes over I2C with minimal hand holding and polling in code? Should I just fork the library to increase the buffer and thus do the exact same thing I did on the Due? Or is repeatedly writing 32 bytes with no stops in between a decent approach?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,904
    Alternate to wire for T_3.x is i2c_t3 , but not updated for 1062 based Teensy.

    It has this not in the .h:
    Code:
    // ------------------------------------------------------------------------------------------------------
    // Tx/Rx buffer sizes - modify these as needed.  Buffers should be large enough to hold:
    //                      Target Addr + Data payload.  Default is: 1byte Addr + 258byte Data
    //                      (this can be substantially reduced if working with sensors or small data packets)
    //
    #define I2C_TX_BUFFER_LENGTH 259
    #define I2C_RX_BUFFER_LENGTH 259
    Not sure how that might apply to the WIRE library and {local install}\hardware\teensy\avr\libraries\Wire\WireIM XRT.h
    Code:
    #define BUFFER_LENGTH 32
    But the length vars in the header are only : uint8_t
    So anything over 255 would break them ... if not anything else

  3. #3
    Thanks. It sounds like I probably should do what I did on the Due and just edit the library to create a buffer of the proper size. It isn't really that difficult to do; I just wanted to avoid it because then I have to distribute the changed library. But, I can probably just go ahead and dump the modified Wire library straight into the source code of the application so that library dependencies for that custom library aren't a problem.

Posting Permissions

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