ADC->adc_timer_dma with Adafruit SSD1306 128x32 I2C

Jeff_805

Member
Hey All,

Individually, these example programs work as expected on a Teensy 4.1 (analog readings are taken and reported to serial monitor / OLED goes through its demonstration). When I combine these two example programs into one (I stripped down the SSD128x32 one to only show some text - not all the graphics), the Teensy repeatedly reboots (whether &Wire1 or &Wire2). Obviously, looking for some help on this one. Is it possible to get them working together?

C:
#include <ADC.h>

#if defined(ADC_USE_DMA) && defined(ADC_USE_TIMER)

#include <AnalogBufferDMA.h>
#include <DMAChannel.h>

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

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// On Teensy 4.1: &Wire, &Wire1, or &Wire2
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire2, OLED_RESET);

//#define PRINT_DEBUG_INFO

// This version uses both ADC1 and ADC2
#ifdef ADC_DUAL_ADCS
const int readPin_adc_0 = A0;
const int readPin_adc_1 = A2;
#else
const int readPin_adc_0 = A0;
const int readPin_adc_1 = 26;
#endif

ADC *adc = new ADC(); // adc object
const uint32_t initial_average_value = 2048;

extern void dumpDMA_structures(DMABaseClass *dmabc);
elapsedMillis elapsed_sinc_last_display;

// Going to try two buffers here  using 2 dmaSettings and a DMAChannel

const uint32_t buffer_size = 1600;
DMAMEM static volatile uint16_t __attribute__((aligned(32)))
dma_adc_buff1[buffer_size];
DMAMEM static volatile uint16_t __attribute__((aligned(32)))
dma_adc_buff2[buffer_size];
AnalogBufferDMA abdma1(dma_adc_buff1, buffer_size, dma_adc_buff2, buffer_size);

#ifdef ADC_DUAL_ADCS
DMAMEM static volatile uint16_t __attribute__((aligned(32)))
dma_adc_buff2_1[buffer_size];
DMAMEM static volatile uint16_t __attribute__((aligned(32)))
dma_adc_buff2_2[buffer_size];
AnalogBufferDMA abdma2(dma_adc_buff2_1, buffer_size, dma_adc_buff2_2,
                       buffer_size);
#endif

void setup() {
  Serial.begin(9600);
  while (!Serial && millis() < 5000)
    ;

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(readPin_adc_0, INPUT_DISABLE); // Not sure this does anything for us
#ifdef ADC_DUAL_ADCS
  pinMode(readPin_adc_1, INPUT_DISABLE);
#endif

  Serial.println("Setup both ADCs");
  // Setup both ADCs
  adc->adc0->setAveraging(8);   // set number of averages
  adc->adc0->setResolution(12); // set bits of resolution
#ifdef ADC_DUAL_ADCS
  adc->adc1->setAveraging(8);   // set number of averages
  adc->adc1->setResolution(12); // set bits of resolution
#endif

  // enable DMA and interrupts
  // Serial.println("before enableDMA"); Serial.flush();

  // setup a DMA Channel.
  // Now lets see the different things that RingbufferDMA setup for us before
  abdma1.init(adc, ADC_0 /*, DMAMUX_SOURCE_ADC_ETC*/);
  abdma1.userData(initial_average_value); // save away initial starting average
#ifdef ADC_DUAL_ADCS
  abdma2.init(adc, ADC_1 /*, DMAMUX_SOURCE_ADC_ETC*/);
  abdma2.userData(initial_average_value); // save away initial starting average
#endif
  // Serial.println("After enableDMA"); Serial.flush();

  // Start the dma operation..
  adc->adc0->startSingleRead(
      readPin_adc_0); // call this to setup everything before the Timer starts,
                      // differential is also possible
  adc->adc0->startTimer(3000); // frequency in Hz

  // Start the dma operation..
#ifdef ADC_DUAL_ADCS
  adc->adc1->startSingleRead(
      readPin_adc_1); // call this to setup everything before the Timer starts,
                      // differential is also possible
  adc->adc1->startTimer(3000); // frequency in Hz
#endif

  print_debug_information();

  Serial.println("End Setup");
  elapsed_sinc_last_display = 0;
    
    delay(2000);
    testdrawstyles();
}

void loop() {

  // Maybe only when both have triggered?
#ifdef ADC_DUAL_ADCS
  if (abdma1.interrupted() && (abdma2.interrupted())) {
    if (abdma1.interrupted()) {
      ProcessAnalogData(&abdma1, 0);
    }
    if (abdma2.interrupted()) {
      ProcessAnalogData(&abdma2, 1);
    }
    Serial.println();
    elapsed_sinc_last_display = 0;
  }
#else
  if (abdma1.interrupted()) {
    ProcessAnalogData(&abdma1, 0);
    Serial.println();
    elapsed_sinc_last_display = 0;
  }
#endif
  if (elapsed_sinc_last_display > 5000) {
    // Nothing in 5 seconds, show a heart beat.
    digitalWriteFast(13, HIGH);
    delay(250);
    digitalWriteFast(13, LOW);
    delay(250);
    digitalWriteFast(13, HIGH);
    delay(250);
    digitalWriteFast(13, LOW);
    elapsed_sinc_last_display = 0;
  }
}

void ProcessAnalogData(AnalogBufferDMA *pabdma, int8_t adc_num) {
  uint32_t sum_values = 0;
  uint16_t min_val = 0xffff;
  uint16_t max_val = 0;

  uint32_t average_value = pabdma->userData();

  volatile uint16_t *pbuffer = pabdma->bufferLastISRFilled();
  volatile uint16_t *end_pbuffer = pbuffer + pabdma->bufferCountLastISRFilled();

  float sum_delta_sq = 0.0;
  if ((uint32_t)pbuffer >= 0x20200000u)
    arm_dcache_delete((void *)pbuffer, sizeof(dma_adc_buff1));
  while (pbuffer < end_pbuffer) {
    if (*pbuffer < min_val)
      min_val = *pbuffer;
    if (*pbuffer > max_val)
      max_val = *pbuffer;
    sum_values += *pbuffer;
    int delta_from_center = (int)*pbuffer - average_value;
    sum_delta_sq += delta_from_center * delta_from_center;

    pbuffer++;
  }

  int rms = sqrt(sum_delta_sq / buffer_size);
  average_value = sum_values / buffer_size;
  Serial.printf(" %d - %u(%u): %u <= %u <= %u %d ", adc_num,
                pabdma->interruptCount(), pabdma->interruptDeltaTime(), min_val,
                average_value, max_val, rms);
  pabdma->clearInterrupt();

  pabdma->userData(average_value);
}

void print_debug_information() {
#ifdef PRINT_DEBUG_INFO
  // Lets again try dumping lots of data.
  Serial.println("\n*** DMA structures for ADC_0 ***");
  dumpDMA_structures(&(abdma1._dmachannel_adc));
  dumpDMA_structures(&(abdma1._dmasettings_adc[0]));
  dumpDMA_structures(&(abdma1._dmasettings_adc[1]));
  Serial.println("\n*** DMA structures for ADC_1 ***");
  dumpDMA_structures(&(abdma2._dmachannel_adc));
  dumpDMA_structures(&(abdma2._dmasettings_adc[0]));
  dumpDMA_structures(&(abdma2._dmasettings_adc[1]));

#if defined(__IMXRT1062__)

  Serial.println("\n*** ADC and ADC_ETC ***");
  Serial.printf("ADC1: HC0:%x HS:%x CFG:%x GC:%x GS:%x\n", IMXRT_ADC1.HC0,
                IMXRT_ADC1.HS, IMXRT_ADC1.CFG, IMXRT_ADC1.GC, IMXRT_ADC1.GS);
  Serial.printf("ADC2: HC0:%x HS:%x CFG:%x GC:%x GS:%x\n", IMXRT_ADC2.HC0,
                IMXRT_ADC2.HS, IMXRT_ADC2.CFG, IMXRT_ADC2.GC, IMXRT_ADC2.GS);
  Serial.printf("ADC_ETC: CTRL:%x DONE0_1:%x DONE2_ERR:%x DMA: %x\n",
                IMXRT_ADC_ETC.CTRL, IMXRT_ADC_ETC.DONE0_1_IRQ,
                IMXRT_ADC_ETC.DONE2_ERR_IRQ, IMXRT_ADC_ETC.DMA_CTRL);
  for (uint8_t trig = 0; trig < 8; trig++) {
    Serial.printf("    TRIG[%d] CTRL: %x CHAIN_1_0:%x\n", trig,
                  IMXRT_ADC_ETC.TRIG[trig].CTRL,
                  IMXRT_ADC_ETC.TRIG[trig].CHAIN_1_0);
  }
#endif
#endif
}

#ifdef PRINT_DEBUG_INFO
void dumpDMA_structures(DMABaseClass *dmabc) {
  Serial.printf("%x %x:", (uint32_t)dmabc, (uint32_t)dmabc->TCD);

  Serial.printf(
      "SA:%x SO:%d AT:%x NB:%x SL:%d DA:%x DO: %d CI:%x DL:%x CS:%x BI:%x\n",
      (uint32_t)dmabc->TCD->SADDR, dmabc->TCD->SOFF, dmabc->TCD->ATTR,
      dmabc->TCD->NBYTES, dmabc->TCD->SLAST, (uint32_t)dmabc->TCD->DADDR,
      dmabc->TCD->DOFF, dmabc->TCD->CITER, dmabc->TCD->DLASTSGA,
      dmabc->TCD->CSR, dmabc->TCD->BITER);
}
#endif

#else  // make sure the example can run for any boards (automated testing)
void setup() {}
void loop() {}
#endif // ADC_USE_TIMER and DMA

void testdrawstyles(void) {
 
    display.clearDisplay();
  display.setTextSize(2);             // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE);        // Draw white text
  display.setCursor(0,0);             // Start at top-left corner
  display.println(F("Hello World!"));
  display.display();
  delay(10000);
    
    display.clearDisplay();
    display.setTextSize(1);             // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
    display.setCursor(0,0);
  display.println(F("Events=255"));
    display.println(F("Max=3000"));
    display.println(F("Min=1000"));
    display.display();
    delay(10000);
    
    display.clearDisplay();
    display.display();
}
 
Try adding CrashReport and see if it shows anything…

after Serial.begin…
add line
if(CrashReport) Serial.print(CrashReport);

and see if it prints anything
 
Wow! Didn't know you could do that. Here is what it reported:

Code:
CrashReport:
  A problem occurred at (system time) 19:1:28
  Code was executing from address 0x57B2
  CFSR: 82
    (DACCVIOL) Data Access Violation
    (MMARVALID) Accessed Address: 0x0 (nullptr)
      Check code at 0x57B2 - very likely a bug!
      Run "addr2line -e mysketch.ino.elf 0x57B2" for filename & line number.
  Temperature inside the chip was 46.76 °C
  Startup CPU clock speed is 600MHz
  Reboot was caused by auto reboot after fault or bad interrupt detected
Setup both ADCs
End Setup
 
So, I did some digging to figure out how to run "addr2line -e mysketch.ino.elf 0x57B2" as I didn't know a .elf file existed for my application. However, I eventually brought Teensyduino to the foreground, click on "File" and "Open HEX File" which showed me where the HEX file was located. Browsing to this directory also showed me the .elf file (all this explained for the other people like me who didn't know where to find this file).

Running the command "addr2line -e mysketch.ino.elf 0x57B2" just ran me head first into the next problem... which has me dead in the water:
Code:
C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724>addr2line -e Reset_Lib_Conflict.ino.elf 0x57B2
addr2line: Dwarf Error: Can't find .debug_ranges section.
??:?
 
@Jeff_805: Don't know for certain that this will make any difference, but try building with the "Tools / Optimize" setting in the Arduino IDE set to "Debug".

Hope that helps . . .

Mark J Culross
KD5RXT
 
I think you might not have the right build of addr2line. You should be using the one that gets installed with Teensyduino. It's buried somewhere under tools/teensy-compile... should be named arm-none-eabi-addr2line.exe.
 
Hello @kd5rxt-mark,

Thank you for helping me with this. I turned this setting on, but it didn't produce anything obvious to me. Here is the new feedback at Serial Monitor:
Code:
CrashReport:
  A problem occurred at (system time) 8:48:27
  Code was executing from address 0x56B6
  CFSR: 82
    (DACCVIOL) Data Access Violation
    (MMARVALID) Accessed Address: 0x0 (nullptr)
      Check code at 0x56B6 - very likely a bug!
      Run "addr2line -e mysketch.ino.elf 0x56B6" for filename & line number.
  Temperature inside the chip was 40.29 °C
  Startup CPU clock speed is 600MHz
  Reboot was caused by auto reboot after fault or bad interrupt detected
Setup both ADCs
End Setup

Here is the output from compiler (not sure it helps - no obvious errors):
Code:
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\jeffs\Documents\Arduino\libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=ogstd,keys=en-us -ide-version=10819 -build-path C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724 -warnings=all -build-cache C:\Users\jeffs\AppData\Local\Temp\arduino_cache_289804 -verbose C:\Users\jeffs\Documents\Arduino\Issues\Reset_Lib_Conflict\Reset_Lib_Conflict.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\jeffs\Documents\Arduino\libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=ogstd,keys=en-us -ide-version=10819 -build-path C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724 -warnings=all -build-cache C:\Users\jeffs\AppData\Local\Temp\arduino_cache_289804 -verbose C:\Users\jeffs\Documents\Arduino\Issues\Reset_Lib_Conflict\Reset_Lib_Conflict.ino
Using board 'teensy41' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Using core 'teensy4' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for ADC.h: [ADC-master@9.2 ADC@9.1]
ResolveLibrary(ADC.h)
  -> candidates: [ADC-master@9.2 ADC@9.1]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for Adafruit_GFX.h: [Adafruit_GFX_Library@1.11.9]
ResolveLibrary(Adafruit_GFX.h)
  -> candidates: [Adafruit_GFX_Library@1.11.9]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for Adafruit_I2CDevice.h: [Adafruit_BusIO@1.16.1]
ResolveLibrary(Adafruit_I2CDevice.h)
  -> candidates: [Adafruit_BusIO@1.16.1]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Alternatives for Adafruit_SSD1306.h: [Adafruit_SSD1306@2.5.10]
ResolveLibrary(Adafruit_SSD1306.h)
  -> candidates: [Adafruit_SSD1306@2.5.10]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_SSD1306" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o nul
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC\ADC.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC\ADC_Module.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC\AnalogBufferDMA.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\Wire.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\WireIMXRT.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\WireKinetis.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\utility\twi.c
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_GFX_Library\Adafruit_GFX.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_GFX_Library\Adafruit_GrayOLED.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_GFX_Library\Adafruit_SPITFT.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_GFX_Library\glcdfont.c
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI\SPI.cpp
Using cached library dependencies for file: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_SSD1306" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/precompile_helper" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr/cores/teensy4" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -x c++-header -Og -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr/cores/teensy4" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/pch/Arduino.h" -o "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/pch/Arduino.h.gch"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\pch\Arduino.h.gch
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -Og -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/pch" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\ADC" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\jeffs\\Documents\\Arduino\\libraries\\Adafruit_SSD1306" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp" -o "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp.o"
Compiling libraries...
Compiling library "ADC"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\ADC\ADC.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\ADC\ADC_Module.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\ADC\AnalogBufferDMA.cpp.o
Compiling library "Wire"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Wire\Wire.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Wire\WireKinetis.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Wire\WireIMXRT.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Wire\utility\twi.c.o
Compiling library "Adafruit_GFX_Library"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_GFX_Library\glcdfont.c.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_GFX_Library\Adafruit_SPITFT.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_GFX_Library\Adafruit_GrayOLED.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_GFX_Library\Adafruit_GFX.cpp.o
Compiling library "Adafruit_BusIO"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp.o
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp.o
Compiling library "SPI"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\SPI\SPI.cpp.o
Compiling library "Adafruit_SSD1306"
Using previously compiled file: C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o
Compiling core...
Using precompiled core: C:\Users\jeffs\AppData\Local\Temp\arduino_cache_289804\core\core_3c79d0f39d0d1b6b64af9518e113e3fa.a
Linking everything together...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-gcc" -Og -Wl,--gc-sections,--relax "-TC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4/imxrt1062_t41.ld" -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\sketch\\Reset_Lib_Conflict.ino.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\ADC\\ADC.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\ADC\\ADC_Module.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\ADC\\AnalogBufferDMA.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Wire\\WireIMXRT.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Wire\\WireKinetis.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_GFX_Library\\glcdfont.c.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_GFX_Library\\Adafruit_GFX.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_GFX_Library\\Adafruit_GrayOLED.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_GFX_Library\\Adafruit_SPITFT.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_BusIO\\Adafruit_BusIO_Register.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_BusIO\\Adafruit_I2CDevice.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_BusIO\\Adafruit_SPIDevice.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724\\libraries\\Adafruit_SSD1306\\Adafruit_SSD1306.cpp.o" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/..\\arduino_cache_289804\\core\\core_3c79d0f39d0d1b6b64af9518e113e3fa.a" "-LC:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724" -larm_cortexM7lfsp_math -lm -lstdc++
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.eep"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.hex"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/teensy_secure" encrypthex TEENSY41 "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.hex"
No key .pem file found, skipping .ehex encryption
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/teensy_post_compile" -file=Reset_Lib_Conflict.ino "-path=C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724" "-tools=C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/" -board=TEENSY41
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/stdout_redirect" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.sym" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objdump" -t -C "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/teensy_size" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf"
Memory Usage on Teensy 4.1:
  FLASH: code:48888, data:12716, headers:9048   free for files:8055812
   RAM1: variables:12992, code:44072, padding:21464   free for local variables:445760
   RAM2: variables:25216  free for malloc/new:499072
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/stdout_redirect" "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.lst" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objdump" -d -S -C "C:\\Users\\jeffs\\AppData\\Local\\Temp\\arduino_build_571724/Reset_Lib_Conflict.ino.elf"
Multiple libraries were found for "ADC.h"
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC
 Not used: C:\Users\jeffs\Documents\Arduino\libraries\ADC-master
Using library ADC at version 9.1 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire
Using library Adafruit_GFX_Library at version 1.11.9 in folder: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_GFX_Library
Using library Adafruit_BusIO at version 1.16.1 in folder: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_BusIO
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
Using library Adafruit_SSD1306 at version 2.5.10 in folder: C:\Users\jeffs\Documents\Arduino\libraries\Adafruit_SSD1306
 
Hello @jmarsh,

Thank you for helping me with this. I think I found the file and referenced it specifically. However, it didn't appear to produce anything of value:
Code:
C:\Users\jeffs\AppData\Local\Temp\arduino_build_571724>"C:\Program Files (x86)\Arduino\hardware\tools\arm\bin\arm-none-eabi-addr2line.exe" -e Reset_Lib_Conflict.ino.elf 0x56B6
??:?
 
There were reports several years ago that the Wire library did not play well with other devices that generate lots of interrupts. Two ADCs interrupting 3000 times per second may be enough to mess with Wire transmissions. Getting the Crash Report to work will let you know whether the crash is originating in your code or in one of the called libraries.

I suggest that you use the "Export Compiled Binary" option in the Sketch menu of the Arduino IDE. That will generate the ELF and listing files in a 'Build' folder in your sketch folder.
 
I used TeensyDebug to trace the issue as far as a call to memset(), which is in a binary library with no debug information so no line number available. Unfortunately the backtrace just told me the stack was corrupt, so I couldn't pinpoint the calling function.

However, looking at the various data structures towards the end of execution of setup(), I noticed that display has a null pointer in its buffer member, and perusing the SSD1306 source and supplied sketch, it looks as if you're missing a call to display.begin(). Inserting that seems to produce results, though without your hardware I suspect they're meaningless!
 
I want to apologize and close the loop on this one. I must have previewed my response months ago but forgot to hit the "post" button. Anyway, your detective work @h4yn0nnym0u5e was spot on. I thought I had combined the two sample programs without removing any non-overlapping code (overlapping code being Serial.begin(), for example). However, in my haste to combine these programs for troubleshooting purposes, I must have mistaken display.begin() for Serial.begin() and deleted it from the example OLED code. It's embarrassing, but that's what happened. Thank ALL of you for your help and feedback. Much appreciated.
 
Back
Top