Seeed XIAO BLE Sense pinMode() and digitalWrite() stop working after Wire.end()

I was using Arduino Wire library to perform I2C master. The board I selected was Seeed nRF52 mbed-enabled boards → Seeed XIAO BLE Sense - nRF52840. The SCL was a multi-purpose pin which sometimes needed to be controlled with pinMode() and digitalWrite() after I2C communications. The problem I encountered was, once the I2C communication already happened, if I wanted to take SCL back with Wire.end(), pinMode() and digitalWrite() had no effect. Here is the code,


      digitalWrite(SCL_PIN, HIGH);
      pinMode(SCL_PIN, OUTPUT);
      digitalWrite(SCL_PIN, LOW);
      digitalWrite(SCL_PIN, HIGH);
      pinMode(SCL_PIN, INPUT);


I tried multiple SCL pins. None was working.
Any help will be highly appreciated.

Hi there,
You may want to Use the GPIO pin number directly after the Wire.end.
See if that works. (perhaps the macro I2C doesn’t release it?)
my .02
GL :slight_smile: PJ

It doesn’t seem possible. Actually, if I put the same pinMode() and digitalWrite() before Wire.begin() was ever called, I could see the pulse I generated on SCL.

Hi there,
That seems normal , If before it’s called. What about a hard coded end of transmission? or transaction possible? Why wouldn’t it release it’s config of the pin?
Can you put some delay in there, Like a whole second or even try “Delay(500);” a half sec.
GL :slight_smile: PJ
can you post the code here? and why 2 threads?

i think wire end is designed to end the wire configuration, and would be expected to clean up nd free those pins…