diff --git a/libraries/ESP_I2S/src/ESP_I2S.cpp b/libraries/ESP_I2S/src/ESP_I2S.cpp index 0ac1e176dc8..77fa6177361 100644 --- a/libraries/ESP_I2S/src/ESP_I2S.cpp +++ b/libraries/ESP_I2S/src/ESP_I2S.cpp @@ -719,9 +719,15 @@ bool I2SClass::end() { #if SOC_I2S_SUPPORTS_TDM case I2S_MODE_TDM: #endif - perimanClearPinBus(_mclk); - perimanClearPinBus(_bclk); - perimanClearPinBus(_ws); + if(_mclk >= 0) { + perimanClearPinBus(_mclk); + } + if(_bclk >= 0) { + perimanClearPinBus(_bclk); + } + if(_ws >= 0) { + perimanClearPinBus(_ws); + } if (_dout >= 0) { perimanClearPinBus(_dout); }