setWatch and neopixel error

Posted on
  • Hi! I've got a problem & solution (took me several days to find it.. phew!..).
    I set watch to rising (or falling) D31 and try to lit a neopixel on D2. And Puck (v2.08) hangs..

    setWatch(()=>{console.log('D31 rises!');}, D31, {edge: 'rising', repeat:true}); //D30 here will cure the issue
    require("neopixel").write(D2, [100,100,100,100,100,100]);
    

    If I set e.g. D30 instead of D31, all's ok. The issue is same on a new Puck without any connection to neopixel, one can try the code out of the box. Would be grateful for a comment:

    1. Is there any constraints on pins when using neopixels?
    2. Just to confirm - if I e.g. set watch to LED and then try to lit it, it does not lit. That's probably because a watch blocks output pinMode, right?
  • Hi! Thanks for this - I can confirm it's the same for me too.

    HOWEVER if you're using the latest 2v09 firmware, it doesn't crash unless you short D31 to something (but you do get pin state change events).

    Is there any constraints on pins when using neopixels?

    You can't use pin D22 since that has to be used as a clock output (it can't be disabled).

    However, it seems that the hardware issue of not being able to disable pins is much wider spread than I thought: https://infocenter.nordicsemi.com/index.­jsp?topic=%2Ferrata_nRF52832_Rev2%2FERR%­2FnRF52832%2FRev2%2Flatest%2Ferr_832.htm­l

    The implication here is that it's not just the clock output pin, but all of them. Generally to set a pin to unused, you set all the bits in the register to 1, so it's probably no coincidence that the 31 from D31 is binary 11111.

    I've just had a go at setting the outputs to other things, but with no success so far. So I'm afraid, at the moment, you'll just have to assume that pin D31 can't be used when you're using Neopixels.

    I'll file an issue for this though and will see if anything can be done about it.

    Just to confirm - if I e.g. set watch to LED and then try to lit it, it does not lit. That's probably because a watch blocks output pinMode, right?

    Yes, that's right - you can probably change it by manually calling pinMode, but by default setWatch would change the pin state to an input.

  • Gordon, many thanks for the feedback and a useful link to NRF errata!
    Installed v2.09, now the code above does not crash and gives 5 rises - perhaps, that's binary 31 as you assume.

    Yes, that's right - you can probably change it by manually calling pinMode, but by default setWatch would change the pin state to an input.

    On v2.08 pinMode change did not work. But on v2.09 LED lits normally after setWatch :) Watch is not raised.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

setWatch and neopixel error

Posted by Avatar for AndreyVS @AndreyVS

Actions