• In order to use P0.09 and P0.10 as GPIOs (requires to "cut" the NFC antenna in order to remove the intrinsic short circuit made by the antenna), one must write into NFCPINSregister (addr offset 0x20C) the value 0x00000000 in order to disable NFC on those pins. (ref: http://infocenter.nordicsemi.com/topic/c­om.nordic.infocenter.nrf52832.ps.v1.1/ui­cr.html#register.NFCPINS )
    On STM32 chips there are peek/poke functions for register access. What about the NRF52?

  • On STM32 chips there are peek/poke functions for register access. What about the NRF52?

    It's exactly the same, on all platforms.

    However you need to reboot the whole device (!) for it to take effect! https://devzone.nordicsemi.com/question/­82143/using-gpio-10-nfc-pin-to-drive-spi­-sclk/

    Are you actually using a Puck.js and are trying to get the pins working, or are you using a bare nRF52?

  • I plan to use a Puck.js for my application because of its form-factor. But I may use the NRF52DK for debugging, I don't want to burn my Puck.js :-)

  • Neat! I hope you're handy with a soldering iron then :)

    It's frustrating about the pin swapping - it's something I wanted to do originally (hence the capacitive sense in the KickStarter) but the reboot just didn't seem worth the hassle.

    Also, that example uses nrf_nvmc_write_word which implies that it's flash memory? If so you'll need require("Flash")

  • Ouch I never used the flash module. Does it handle pages internally? Or do the user have to read+mask->erase flash->write flash?

  • If you want to set bits back to 1 then yes, you'll have to read+mask pages, however there is a utility there to figure out where each page is.

    Having said that, it's possible the Flash module will refuse to write to that address out of the box on Puck.js as I didn't want people bricking devices :) I literally just added a workaround as a commit yesterday! https://github.com/espruino/Espruino/com­mit/5fedb5c58f62f197733f17cc4de97258edaa­724f

  • How did you know I would need this feature today? ;-)

    var f=require("Flash");
    var NFCPINSreg=0x1000120C;
    f.write(0xFFFFFFFE, NFCPINSreg)

    Does this code seem to be the way to go?

  • Looks promising, yes!

  • Hmm, does the Flash module really exist? Or has it been replaced by FlashEEPROM ?

  • No, it does really exist. It's just built in, so there isn't a JS version.

  • I just tried to unlock flash and write to the NFCPINS register with the latest build 2017-11-27 :

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v94 Copyright 2017 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    >var f=require('Flash')
    =function () { [native code] }
    >var NFCPINSreg=0x1000120C
    >var NFCPINSdata=[0xff,0xff,0xff,0xfe]
    =[ 255, 255, 255, 254 ]
    ={ "deepSleep": 0, "pretokenise": 0, "unsafeFlash": 0 }
    ={ "deepSleep": 0, "pretokenise": 0, "unsafeFlash": 1 }
    =new Uint8Array([255, 255, 255, 255])
    =new Uint8Array([255, 255, 255, 255])

    Despite the flag unsafeFlash being set to 1, it seems that the flash register did not change. Any idea?

  • I'm afraid not - it's possible it needs some other unlocking, since it's not in the 'normal' flash memory area

  • Following this topic (https://devzone.nordicsemi.com/question/­67300/writing-to-uicr-from-application-c­ode/) it seems that the flash needs to be Write Enabled by writing 0x01 into CONFIG reg at addr 0x4001E504.
    I use poke32for that, like following:

    var NVMCCONFIGreg=0x4001E504;

    This instruction has the effect of disconnecting the Puck.js from the IDE (reset?)
    Does anyone ever used poke32 on a NRF52?

  • Does anyone ever used poke32 on a NRF52?

    Oh yes, a lot - for instance with http://www.espruino.com/NRF52LL

    So I think it's that particular register.

    I imagine you get the 3 LEDS lighting up? That's caused by the softdevice throwing an internal error - at that point the only thing Espruino can do is to reboot.

    I think realistically you might be better off trying to build your own firmware with NFC disabled - it's probably easier to do it from C-land. Or, depending on what you're trying you could unsolder the IR LED and use those pins, or perhaps use an IO expander? :)

  • Using the IR LED as an additionnal GPIO would definitely be a better idea

  • You actually get two GPIOs, because Puck.js cheats and uses one pin to do 40kHz PWM and another to actually turn it on and off

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

peek/poke or other method to write direct into nrf52 registers?

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey