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

Thread: Teensy 3.2 Code Doesn't Reliably Run on Teensy LC

  1. #1

    Teensy 3.2 Code Doesn't Reliably Run on Teensy LC

    I recently designed a simple device based on a Teensy 3.2 that uses an OLED display via I2C. The software was based on the Adafruit SSD1306 and GFX library. The hardware interface to the OLED display is simply the SDA and SCL lines with 4K7 pull-up resistors. There are no other devices on the I2C bus, and the PCB trace length is quite short. Everything It's a menu driven system with some buttons that do the typical switching between menus and scrolling up and down through values.

    Everything works perfectly on the Teensy 3.2. I then swapped-in a Teensy LC to save cost, as we will eventually build at least a hundred of these. The migration was simply swapping the physical module, then switching boards in the Arduino compiler from the 3.2 to the LC.

    Running on the LC the OLED display now displays corrupted information, and the display tends to scroll one column of pixels from left to right each time it is updated. When I swap back to the Teensy 3.2 it works fine. I tried swapping in and out several 3.2 and LC modules, and the fault remained consistent with the use of the LC.

    Some sample code is posted below. There's not much point in posting any more code as the code is fine because it works on the Teensy 3.2. The hardware is straightforward. I did try lowering the I2C resistors down to 1K each as an experiment, but with no significant impact. My only possible conclusion issue is a timing issue with the I2C interface. I tried lowering the SCL clock frequency with Wire.setClock(100000) but that had no effect.

    Any thoughts ?

    Here is a code snippet:

    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    Code from one of the routines called from the main loop:
    // Initialise the display
    // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
    if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Adafruit library address 0x3D for 128x64, however we found that 3C is correct for our display.
    Serial.println(F("SSD1306 allocation failed"));
    //for (;; // Don't proceed, loop forever

    display.fillRect(0, 0, display.width() - 1, display.height() - 1 , WHITE); // Fill the display with white
    display.setTextSize(2); // Draw 2X-scale text
    display.setTextColor(BLACK, WHITE); // Draw black text on white background
    display.setCursor(0, 12); // Set position for title text
    display.println(" Product");
    display.setCursor(0, 36); // Set position for title text
    display.println(" Name");
    display.drawRect(2, 2, display.width() - 5, display.height() - 5 , BLACK); // Draw a black border offset from the edge
    display.display(); // Update screen

  2. #2
    Senior Member
    Join Date
    Nov 2012
    The LC is quite a bit slower than a T3.2 and it has much less flash and ram memory. Either or both of these could conspire against you but I can't tell just from your snippet.


  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Power issue?

    I believe the LC has a smaller 3.3v voltage regulator, which says you have about 100mA max whereas the 3.2 250mA... So depending on your setup maybe power issue?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    One quick way to check if you're low on RAM is to set Tools > USB Type to "No USB". That will save some RAM, but of course you get absolutely no USB communication (so you'll have to press the button to initiate uploading new programs). If it crashes the same way, then you should probably look elsewhere than the RAM running out.

  5. #5

    Thanks for the tips. Paul, I tried compiling without USB support but that didn't resolve the problem. Are there ways to assess RAM consumption from the Arduino environment ? Functionally the code is all compiling and running OK, except for the I2C OLED display glitches. The code itself is not overly complicated, mostly scanning switches, a few elapsedMillis timers, and the display updates.

    Regarding the suggestions about the power issues....... The Teensy and other support circuitry are all running from an external 3.3V LDO directly connected to the 3V3 terminal on the Teensy. The input to the Teensy's regulator is not connected. The USB voltage trace has been cut.

Posting Permissions

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