Initializing 2nd OLED display gives EXCVADDR:0x00000000

pwn-gh
Posts: 2
Joined: Tue Mar 08, 2022 6:09 am

Initializing 2nd OLED display gives EXCVADDR:0x00000000

Postby pwn-gh » Sun Mar 13, 2022 7:38 am

After I added another OLED display, the Initialize routine seems to cause crashes, but I don't know how to fix it.
Screenshot (12).png
Debugger screenshot
Screenshot (12).png (201.59 KiB) Viewed 1522 times
Code is below

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4000c46c PS : 0x00060730 A0 : 0x800d226c A1 : 0x3ffb1f30
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000400 A5 : 0x00000000
A6 : 0x000000ff A7 : 0x00000040 A8 : 0x800d3ce0 A9 : 0x3ffb1f00
A10 : 0x00000002 A11 : 0x3f4001dc A12 : 0x00000000 A13 : 0x00000064
A14 : 0x00000019 A15 : 0x60013000 SAR : 0x00000017 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x0000003f

ELF file SHA256: 0000000000000000

Backtrace: 0x4000c46c:0x3ffb1f30 0x400d2269:0x3ffb1f40 0x400d1100:0x3ffb1f60 0x400d1295:0x3ffb1f80 0x400d5842:0x3ffb1fb0 0x40086a75:0x3ffb1fd0

  1. #include <Arduino.h>
  2.  
  3. int bootDelay = 1000;
  4.  
  5. // SSD1306:
  6. #include <Wire.h>
  7. #include <Adafruit_GFX.h>
  8. #include <Adafruit_SSD1306.h>
  9. // Screen width, Screen height, Protocol, Oled reset pin
  10. Adafruit_SSD1306 display(128, 64, &Wire, -1);
  11. bool SSD1306Initialized = false;
  12. void SSD1306Initialize();
  13. Adafruit_SSD1306 display2(128, 64, &Wire, -1);
  14. bool SSD1306_2Initialized = false;
  15. void SSD1306_2Initialize();
  16.  
  17. // BNO055
  18. // #include <Wire.h>
  19. #include <Adafruit_Sensor.h>
  20. #include <Adafruit_BNO055.h>
  21. #include <utility/imumaths.h>
  22. //                                    ID, Address
  23. Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);
  24. bool BNO055Initialized = false;
  25.  
  26. sensors_event_t bnoEulerData , bnoGyrData , bnoLinAccData, bnoMagData, bnoAccData, bnoGravData;
  27. int8_t bnoTempData;
  28. uint8_t bnoSysStatus, bnoGyrStatus, bnoAccStatus, bnoMagStatus = 0; // Calibration data
  29. void BNO055Initialize();
  30. void BNO055GetData();
  31. void BNO055Display();
  32.  
  33. // BME280
  34. #include <Wire.h>
  35. // #include <Adafruit_Sensor.h>
  36. #include <Adafruit_BME280.h>
  37. #define SEALEVELPRESSURE_HPA (1013.25)
  38. Adafruit_BME280 bme;                  // I2C
  39. unsigned long delayTime;
  40. bool BME280Initialized = false;
  41. //         m            hPa            %             m
  42. float bmeTempData , bmePresData , bmeHumiData , bmeAltiData;
  43. void BME280Initialize();
  44. void BME280GetData();
  45.  
  46. void setup() {
  47.   Serial.begin(115200);
  48.   Serial2.begin(115200);
  49.   //Initialize SSD1306 OLED Screen
  50.   SSD1306Initialize();
  51.   SSD1306_2Initialize();
  52.   //Initiaize BNO055 Sensor
  53.   BNO055Initialize();
  54.   //Initiaize BME280 Sensor
  55.   BME280Initialize();
  56.  
  57.   delay(bootDelay);
  58.   display.clearDisplay();
  59.   display.display();
  60. }
  61.  
  62. void loop() {
  63.   uint32_t startTime = millis();
  64.  
  65.   display.clearDisplay();
  66.   // Get BNO055 Data
  67.   BNO055GetData();
  68.   // Get BME280 Data
  69.   BME280GetData();
  70.  
  71.   uint32_t measurementTime = millis();
  72.   measurementTime = measurementTime - startTime;
  73.   startTime = millis();
  74.  
  75.   BNO055Display();
  76.  
  77.   uint32_t displayTime = millis();
  78.   displayTime = displayTime - startTime;
  79.   display.setCursor(0, 56);
  80.   display.printf("time:MS:%i,DISP:%i", measurementTime, displayTime);
  81.   Serial.printf("Measurement Time: %i, Display Time: %i\n", measurementTime, displayTime);
  82.   Serial.println();
  83. }
  84.  
  85. void SSD1306Initialize() {
  86.   SSD1306Initialized = display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // True if successful
  87.   Serial.println(F("SSD1306: Initialization: Begin"));
  88.   if (!SSD1306Initialized) {
  89.     Serial.println(F("SSD1306: Initialization: Failed "));
  90.   } else {
  91.     Serial.println(F("SSD1306: Initialization: Success"));
  92.     display.clearDisplay();
  93.     display.setTextSize(1);
  94.     display.setTextColor(SSD1306_WHITE);
  95.     display.setCursor(0, 0);
  96.     display.cp437(true);
  97.     display.setTextWrap(false);
  98.     display.print(F("CUHAR FC(Debug)"));
  99.     display.display();
  100.   }
  101.   Serial.println(F("SSD1306: Initialization: Done"));
  102. }
  103.  
  104. void SSD1306_2Initialize() {
  105.   SSD1306_2Initialized = display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
  106.   Serial.println(F("SSD1306_2: Initialization: Begin"));
  107.   if (!SSD1306_2Initialized) {
  108.     Serial.println(F("SSD1306: Initialization: Failed "));
  109.   } else {
  110.     Serial.println(F("SSD1306_2: Initialization: Success"));
  111.     display2.clearDisplay();
  112.     display2.setTextSize(1);
  113.     display2.setTextColor(SSD1306_WHITE);
  114.     display2.setCursor(0, 0);
  115.     display2.cp437(true);
  116.     display2.setTextWrap(false);
  117.     display2.print(F("CUHAR FC(Debug),DISP2"));
  118.     display2.display();
  119.   }
  120.   Serial.println(F("SSD1306_2: Initialization: Done"));
  121. }
  122.  
  123. void BNO055Initialize() {
  124.   Serial.println(F("BNO055: Initialization: Begin"));
  125.   BNO055Initialized = bno.begin();
  126.   display.setCursor(0, 8);
  127.   //display2.setCursor(0, 8);
  128.   if (!BNO055Initialized) {
  129.     Serial.println(F("BNO055: Initialization: Failed"));
  130.     display.print(F("BNO055 ... Error"));
  131.     //display2.print(F("BNO055 ... Error"));
  132.   } else {
  133.     Serial.println(F("BNO055: Initialization: Success"));
  134.     display.print(F("BNO055 ... Init"));
  135.     //display2.print(F("BNO055 ... Init"));
  136.   }
  137.   bno.setExtCrystalUse(true);
  138.   Serial.println(F("BNO055: Initialization: SSD1306 Status Set"));
  139.   display.display();
  140.   //display2.display();
  141.   Serial.println(F("BNO055: Initialization: SSD1306 Display()"));
  142. }
  143.  
  144. void BME280Initialize() {
  145.   Serial.println(F("BME280: Initialization: Begin"));
  146.   BME280Initialized = bme.begin(0x77, &Wire);
  147.   display.setCursor(0, 16);
  148.   display2.setCursor(0, 16);
  149.   if (!BME280Initialized) {
  150.     Serial.println(F("BME280: Initialization: Failed."));
  151.     display.print(F("BNO055 ... Error"));
  152.     display2.print(F("BNO055 ... Error"));
  153.   } else {
  154.     Serial.println(F("BME280: Initialization: Success"));
  155.     display.print(F("BME280 ... Init"));
  156.     display2.print(F("BME280 ... Init"));
  157.   }
  158.   bme.setSampling(Adafruit_BME280::MODE_FORCED,
  159.                   Adafruit_BME280::SAMPLING_X16,   // Temperature
  160.                   Adafruit_BME280::SAMPLING_X16,   // Pressure
  161.                   Adafruit_BME280::SAMPLING_X16,   // Humidity
  162.                   Adafruit_BME280::FILTER_X16 );   // IIR filter coefficient
  163.   Serial.println(F("BME280: Initialization: SSD1306 Status Set"));
  164.   display.display();
  165.   display2.display();
  166.   Serial.println(F("BME280: Initialization: SSD1306 Display()"));
  167. }
  168.  
  169. void BNO055GetData() {
  170.   bno.getEvent(&bnoEulerData, Adafruit_BNO055::VECTOR_EULER);        // Euler angle
  171.   bno.getEvent(&bnoGyrData, Adafruit_BNO055::VECTOR_GYROSCOPE);      // Rad/s
  172.   bno.getEvent(&bnoLinAccData, Adafruit_BNO055::VECTOR_LINEARACCEL); // Linear Acceleration
  173.   bno.getEvent(&bnoMagData, Adafruit_BNO055::VECTOR_MAGNETOMETER);   // Magnetometer
  174.   bno.getEvent(&bnoAccData, Adafruit_BNO055::VECTOR_ACCELEROMETER);  // Accelerometer
  175.   bno.getEvent(&bnoGravData, Adafruit_BNO055::VECTOR_GRAVITY);       // Gravity
  176.   bnoTempData = bno.getTemp();                                       // Sensor temperature
  177.   bno.getCalibration(&bnoSysStatus, &bnoGyrStatus, &bnoAccStatus, &bnoMagStatus);// Calibration status
  178. }
  179.  
  180. void BNO055Display(){
  181.   display.setCursor(0, 0);
  182.   display.printf("CL:S:%i, G:%i, A:%i, M:%i", bnoSysStatus, bnoGyrStatus, bnoAccStatus, bnoMagStatus);
  183.   Serial.printf("BNO055: Data: Calibration Status: System: %i, Gyro:%i, Accel:%i, Mag:%i\n", bnoSysStatus, bnoGyrStatus, bnoAccStatus, bnoMagStatus);
  184.   display.setCursor(0, 8);
  185.   display.printf("E:%.2f,%.2f,%.2f", bnoEulerData.orientation.x, bnoEulerData.orientation.y, bnoEulerData.orientation.z);
  186.   Serial.printf("BNO055: Data: Euler: %.2f,%.2f,%.2f\n", bnoEulerData.orientation.x, bnoEulerData.orientation.y, bnoEulerData.orientation.z);
  187.   display.setCursor(0, 16);
  188.   display.printf("G:%.2f,%.2f,%.2f", bnoGyrData.gyro.x, bnoGyrData.gyro.y, bnoGyrData.gyro.z);
  189.   Serial.printf("BNO055: Data: Gyro: %.2f,%.2f,%.2f\n", bnoGyrData.gyro.x, bnoGyrData.gyro.y, bnoGyrData.gyro.z);
  190.   display.setCursor(0, 24);
  191.   display.printf("L:%.2f,%.2f,%.2f\n", bnoLinAccData.acceleration.x, bnoLinAccData.acceleration.y, bnoLinAccData.acceleration.z);
  192.   Serial.printf("BNO055: Data: Linear Acceleration: %.2f,%.2f,%.2f", bnoLinAccData.acceleration.x, bnoLinAccData.acceleration.y, bnoLinAccData.acceleration.z);
  193.   display.setCursor(0, 32);
  194.   display.printf("M:%.2f,%.2f,%.2f\n", bnoMagData.magnetic.x, bnoMagData.magnetic.y, bnoMagData.magnetic.z);
  195.   Serial.printf("BNO055: Data: Magnetometer: %.2f,%.2f,%.2f", bnoMagData.magnetic.x, bnoMagData.magnetic.y, bnoMagData.magnetic.z);
  196.   display.setCursor(0, 40);
  197.   display.printf("A:%.2f,%.2f,%.2f\n", bnoAccData.acceleration.x, bnoAccData.acceleration.y, bnoAccData.acceleration.z);
  198.   Serial.printf("BNO055: Data: Accelerometer: %.2f,%.2f,%.2f", bnoAccData.acceleration.x, bnoAccData.acceleration.y, bnoAccData.acceleration.z);
  199.   display.setCursor(0, 48);
  200.   display.printf("G:%.2f,%.2f,%.2f\n", bnoGravData.acceleration.x, bnoGravData.acceleration.y, bnoGravData.acceleration.z);
  201.   Serial.printf("BNO055: Data: Gravity: %.2f,%.2f,%.2f", bnoGravData.acceleration.x, bnoGravData.acceleration.y, bnoGravData.acceleration.z);
  202.   Serial.println();
  203.   display.display();
  204. }
  205.  
  206. void BME280GetData() {
  207.   bme.takeForcedMeasurement();
  208.   bmeTempData = bme.readTemperature();
  209.   bmePresData = bme.readPressure();
  210.   bmeHumiData = bme.readHumidity();
  211.   bmeAltiData = bme.readAltitude(SEALEVELPRESSURE_HPA);
  212. }

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Initializing 2nd OLED display gives EXCVADDR:0x00000000

Postby ESP_Sprite » Mon Mar 14, 2022 1:01 am

Possibly an issue where the display library doesn't support two displays (at least in the way you use it). Can you decode that backtrace? That usually helps zoom in on the error.

Who is online

Users browsing this forum: No registered users and 69 guests