You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ok, so I managed to reproduce the issue with:

    // Short D11 + D12
    analogWrite(D11, 0.0015, {freq:200});
    //analogWrite(D11, 0.1, {freq:200}); // works fine even with low accuracy
    setWatch(() => n++, D12, {repeat:true,edge:"falling"});
    setInterval(function() {
    }, 1000);

    In the Nordic chips, you can watch a pin either in a Low Power or a High Performance mode. In Espruino 2v09 I moved to using the Low Power mode as it uses substantially less power when the device is idle. What I didn't realise is that the Low Power mode isn't just less accurate, it just doesn't seem to be able to register any pulse that's faster than around 25us.

    So, as a fix I just committed code that allows you to enable the high speed mode using hispeed:true for the watch:

    setWatch(() => n++, D12, {repeat:true,edge:"falling",hispeed:true­});

    This'll allow you to watch faster pin state changes on Nordic chipsets. However the pin 'state' may still be wrong - the pin state is still read in software (it's not reported by the hardware) when the IRQ is executed (which may not be immediately) so as a result a very small positive pulse may instead produce a state=false event because by the time the IRQ has read the pin state the signal has already gone back to 0.


Avatar for Gordon @Gordon started