Here is the I2C example code as I am attempting to run it. Note the #define comment. The code compiles fine, but when it runs I get the following runtime error.
++ MbedOS Error Info ++
Error Status: 0x80010130 Code: 304 Module: 1
Error Message: pinmap not found for peripheral
Location: 0x218CB
Error Value: 0x11
#include “Wire.h”
void testPortI2C(TwoWire &i2c);
// This thread will create its own MbedI2C object using IOM pins
// Define your own pins below to try it
#define mySDA 17 This line and the next line were commented out in the example. I deleted // and added
my SDA and SCL pin numbers from underside of Nano below QWIIC connect.
#define mySCL 18
#if (defined mySDA) && (defined mySCL)
TwoWire myWire(mySDA, mySCL);
#endif
void testPortI2C(TwoWire &i2c){
Serial.printf(“Scanning… (port: 0x%08X), time (ms): %d\n”, (uint32_t)&i2c, millis());
uint8_t detected = 0;
for(uint8_t addr = 1; addr < 127; addr++ ){
// use endTransmission to determine if a device is present at address
i2c.beginTransmission(addr);
uint8_t retval = i2c.endTransmission();
if(retval == 0){
Serial.printf(“\t0x%02X detected\n”, addr);
detected++;
}
}
if(!detected){
Serial.printf(“\tNo device detected!\n”);
}
Serial.println();
}
void setup() {
Serial.begin(115200);
Serial.println(“Apollo3 - I2C”);
pinMode(LED_BUILTIN, OUTPUT);
#if VARIANT_WIRE_INTFCS > 0
Wire.begin();
#endif
#if VARIANT_WIRE_INTFCS > 1
Wire1.begin();
#endif
#if (defined mySDA) && (defined mySCL)
myWire.begin();
#endif
}
void loop() {
#if VARIANT_WIRE_INTFCS > 0
testPortI2C(Wire);
#endif
#if VARIANT_WIRE_INTFCS > 1
testPortI2C(Wire1);
#endif
#if (defined mySDA) && (defined mySCL)
testPortI2C(myWire);
#endif
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
}