• This code works if there's not much data transfer. But it fails as soon as the bus becomes busy, the event queue will simply overflow (getting events at the bus clock frequency). And you skipped the CS detection in this code completely.

    Yes, there's no CS. That'd have to be added as as you note the only way to do it would use up processing power even when CS wasn't asserted.

    And I agree this will fail when there is more than a little bit of traffic on the bus. This is more to humour @Robin and prove that setWatch actually does work ok.

    ... because right now since there's no support for hardware SPI or I2C slave, using Serial would be the sane option for transferring data between two Espruino devices.

  • Quick update as I realize it is late by you, . . . with more testing to do,

    'This is more to humour Robin'

    Okay humored! (sic US sp)


    L2 spi.setup({mosi:D14,sck:D15});

    Took a bit to get up and running, determined PulseView software requires MISO to be included also, for the protocol decoder to work.

    With using just the code from #15

    First thing I noticed is the active state on the pins is not the same. Clock phase. As pinMode() isn't used, I'm guessing looking at default and setup will uncover that.

    Added a setInterval() on send side MDBT42Q so I didn't have to keep pulsing that side, and kept the bus quiet for at least a full second.

    Without the CS detect, the WiFi slave side does decode as in #15

    MDBT sends out 8usec clock ~100KHz


    I don't see any major differences, except for the CS state inclusion.

    Speculation here: Sanity Check

    Commented out strings, outside of functions are not included in the upload? (yes?)

    Inside the CS setWatch() during development, I placed console.log() statements to see what was going on. Had a hunch that the update to the WebIDE console window was getting bogged down, as it took a while to Ctrl+C out. I commented out ~three debug statements, and the console updated fine.

    HUNCH: Even though the console now appeared to be updating without noticeable delay, that in reality, the commented out lines were causing a delay in the setWatch() read perhaps?

    Off for coding CS inclusion and more testing . . . .

  • Commented out strings, outside of functions are not included in the upload? (yes?)

    "it depends" :)

    Without minification, all comments and whitespace is included!
    By default the web ide does NOT minify your "main" code, but does minify the included modules. But check the minification in the settings.

  • console.log() takes a lot of time. If you call it once every 8 bit it's somewhat ok, but if you call it for every bit it'll slow down things significantly. But the read data should be still valid in my understanding.
    For time critical functions it's better to store data you want to print in some variable or array and print it at a later point.

About

Avatar for Robin @Robin started