• Goal to stay between 100000-800000 bits/sec.

    You're totally out of luck then - setWatch is not going to work. Maybe you'll get it working but it'll take ~32ms to process your 32 bits of data in JS - so I don't understand why you want a really high bitrate.

    Can you try this code:

    // out
    var spi = new SPI();
    spi.setup({mosi:D29,sck:D28});
    // in
    pinMode(D31, "input");
    var d=1;
    setWatch(function(e) {
      d=(d<<1)|e.data;
      if (d&256) {
        print("Got "+(d&255));
        d=1;
      }
    },D30,{edge:"rising", data:D31, repeat: true});
    
    // Test
    spi.write([1,2,3,4]);
    

    Just tested this on an nRF52 (all running on the same device) and it's fine, even at the 'normal' speed.

About

Avatar for Gordon @Gordon started