Second I2C on Arduino on MKR1000

Been trying to get a second i2c port working, have modified the variant.cpp to have ti wire interfaces

#define WIRE_INTERFACES_COUNT 2

created these macros to us sercom1

#define PERIPH_WIRE1 sercom1
#define PIN_WIRE1_SDA (8u)
#define PIN_WIRE1_SCL (9u)

If I have no pullups then it would appear that the code I use to send a test message using this function

void SendHostMessage( int Address, int Offset, const char *Message )
{
  Wire1.beginTransmission( Address );
  Wire1.write( Offset );
  Wire1.write( Message );
  int Status = Wire1.endTransmission( );
}

with this call

  SendHostMessage( 0x21, 0x10, "Hallo" );

If I have pullups on the ping PA16,17 then I get 2 cycles of I2C clock and no start condition, I have the default wire interface working fine.

I have a link debugger attached but if I try and debug this code I get a signal handler called, the stack trace looks like this

??@0x00000640 (Unknown Source:0)
<signal handler called>@0xfffffff1 (Unknown Source:0)
impure_data@0x2000005c (Unknown Source:0)
<signal handler called>@0xfffffff9 (Unknown Source:0)
loop@0x00002204 (c:\Icotest\WT36\TestMkrZero\src\main.cpp:76)
main@0x00004f86 (c:\Users\david\.platformio\packages\framework-arduino-samd\cores\arduino\main.cpp:51)

If I remove calls to send on wire1 then debugger works and I can add a breakpoint

If I debug the code with the call to wire1 and no other breakpoints I get this stack trace with code displayed as follows in wire.cpp in “bool SERCOM::sendDataMasterWIRE(uint8_t data)” on line 568:

  while(!sercom->I2CM.INTFLAG.bit.MB) {

I assume that this is an issue in some way with interrupt when in debug, but when not in debug it appears that this is more functional.

Any ideas?