Here are two code snippets, they run from loop. Again, this is a contrived example do demonstration what seems like a bug.

The first works perfectly okay. The second hangs at SPI.transfer16. What I am doing wrong?

Is there another easier way to set the speed? I want to set it for the maximum allowed.


Code:
loop() {

      SPISettings settings(2000000, MSBFIRST, SPI_MODE0);
      
      SPI.begin() ;
      digitalToggleFast(sparePin );
      SPI.transfer16(0xFFFF);
      digitalToggleFast(sparePin );
      SPI.end();

      
      SPI.beginTransaction(settings);
      digitalToggleFast(sparePin );    // pin goes high
      SPI.transfer16(0xFFFF);          // << hangs here, pin never goes low
      digitalToggleFast(sparePin );
      SPI.endTransaction();

    delay(1000);
}