Using pins D9 & D10 on the MDBT42Q #3685
Replies: 48 comments
-
Posted at 2020-10-25 by @fanoush there is persistent setting in UICR register NFCPINS that must have its lowest bit cleared. Run this When this is OK then still those pins are not the same as any other. Check this note , there is increased leakage between them so they affect each other. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by consolenaut Morning! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @gfwilliams When a firmware without NFC enabled boots, it clears the UICR registers automatically to enable the GPIO pins. So actually the easy solution is just to install a firmware with NFC disabled and it'll all magically work - although the official build still has NFC in so we'd have to do a custom build. @fanoush did you find another way to set UICR register values from Espruino? I see that Are these modules you've got from the Espruino shop, or are you programming your own? If you'd programmed your own it should be pretty easy to do a build yourself, otherwise I can get one sorted for you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @fanoush sadly UICR area is not writable when softdevice is enabled, so it is not easily possible without flashing custom build of espruino, it needs -DCONFIG_NFCT_PINS_AS_GPIOS in board file - then it is done automatically as part of application startup. Or you need espruino with patch that can run your javascript to write to UICR as part of NRF.restart() but that is custom build too. Or it can be done via SWD - openocd or other debugger. Easiest perhaps is to rebuild espruino for MDBT42Q from source with that one line in board file. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @fanoush
Yes, there is no nordic api for that https://devzone.nordicsemi.com/f/nordic-q-a/7300/can-sd_flash_write-be-used-to-write-to-the-uicr or https://devzone.nordicsemi.com/f/nordic-q-a/20864/pattern-for-writing-to-uicr-while-soft-device-enabled With that patch I am doing it by poking NVMC
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @gfwilliams When you add that patch, can you simply use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @fanoush see that nordic link, they do not allow UICR address area in softdevice flash writing api (even if they possibly could), so only poking NVMC works |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-26 by @gfwilliams Nice - ok, I've just added some code in for that. I didn't merge your code exactly as it was because actually there are some potentially bad side-effects of trying to execute JS in a IRQ (which can happen if you do So @consolenaut you can now flash a cutting-edge build, then just run the following:
Afterwards you should see |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-27 by consolenaut Just picking this up now, thanks @fanoush& @gfwilliams for your assistance! I've updated my board layout to use two other pins rather than 9 & 10 so this shouldn't be a problem in future, but I'm going to flash the cutting edge build & use the code you shared to get this revision working hopefully. I'm using a pre-baked module from the Espruino store, can I flash a cutting edge build onto it with the ide similar to how I'd update the firmware normally or do I need a a jlink programmer or something more exciting? Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-27 by @fanoush
i've seen a watch (ID107plus HR) where those pins are used as I2c sda/scl and it works. Also in B5 fitness tracker one of them is used as a button and the other one is floating. It can be seen that without any pull set on the other pin it follows value of the button connected to the other pin. so it depends, it can work but maybe using other pins is a better idea. Or using just one of them. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-27 by @gfwilliams
With the ones sold on the store you're sorted - you just need to connect D0(usually BTN1) to VCC when powering the module on - it'll then appear as |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-27 by consolenaut Just to keep you posted, I flashed the cutting edge build onto the board & ran that code, I'm getting There's definitely a chance its either the soldering on the board or some other issue so I'm going to inspect that again first. I've had a previous revision of this board working although using different pins for i2c. I'll try and rule out any soldering or connection issues before taking too much more of your time :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-27 by @fanoush You also need to E.reboot() or power cycle it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-28 by consolenaut I've power cycled a couple of times with no luck, and I've checked over all my connections, the soldering is all good, but still no luck, just getting |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-28 by @gfwilliams Do you have any way of getting a volt meter to test those pins and see if the voltage is changing as you expect when using |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by @gfwilliams
It shouldn't be required, but hopefully this will help to narrow down if it is the issue. Actually I just had a thought. Try:
It's possible the disconnect isn't instant and so NRF.restart doesn't get called. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by natman1970 Thankyou @gfwilliams, that works... I've put in the extra semi-colons...
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by @gfwilliams Great! I'll update the previous post |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by @fanoush
Strange that when you are still connected it tell you this |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by natman1970 I'm struggling to find the link to the Nordic app to try..Must be missing the obvious |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by @gfwilliams
It is called, but it won't execute the JS you gave it :)
For firmware updates? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-01 by natman1970 You really did mean an app (not going down that route)... I've just sent someone instructions to use the URL approach but firmware zip file might change so it won't be right. the local file select function just doesn't work which is a shame. Tried it numerous times.. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by natman1970 @gfwilliams, for clarity, why do we need to restart the "softdevice" to be able to use the poke32 functions? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by @gfwilliams
You mean you never install any apps on your phone? Honestly the NRF Connect app is harmless, ad-free, and very useful when developing with Bluetooth LE.
So what we do is disable the Bluetooth stack, write them, and restart it. You also have to fully reset the device after setting the registers in order for the pins to work. But you only ever have to do this once for each device. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by natman1970 Many thanks for that. Will look at the app then. Its probably more the downloading firmware files from a remote location... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by @gfwilliams I'm not entirely sure I understand the concern here as I imagine this is something you'd do at the factory (or if you're ordering a bunch of MDBT42 from us we can arrange that they are pre-flashed with newer firmware). The Nordic App works from a file saved locally on your Android device. However you're welcome to host the firmware files yourself on your own server if that's an issue. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by natman1970 Will try it.... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-03 by @fanoush
It is an app for Android or iPhone in builtin Google or Apple app store so no downloading of random files. NRF Connect app is made directly by Nordic Semiconductor for testing BLE and flashing Nordic chips. https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-mobile As for poke32 - those 0x4001exxx addresses used are accessing low level NVMC hardware to directly write/erase flash memory. Doing this is protected because it would interrupt bluetooth timing - when writing to flash the CPU is completely halted until write is done which can take relatively long. So the softdevice manages flash access while it is running and writes to flash are carefully timed to not to break bluetooth traffic. If you run that code while bluetooth is on it will immediately reboot. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-23 by @gfwilliams If you haven't sorted this, any chance you could try this code:
It might be the timeout helps since it's possible the board hadn't disconnected right after |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-03-15 by natman1970 @gfwilliams, apologies for not replying initially. It all worked before and tried the above code as well and it changes the registers as intended. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-10-25 by consolenaut
Hey!
I just wanted to ask if there are any gotchas to know about when using pins D9 & D10 on the MDBT42Q module.
I had a PCB fabricated & I'm trying to use those pins to start i2c communication with another device on the board, but I'm getting some exciting errors.
I noted in the docs it says those pins are used for NFC but I'm not using NFC in my code, could that be causing some weirdness? I'm really hoping the answer isn't "You can't use those pins since they're for NFC"
Cheers!
-J
Beta Was this translation helpful? Give feedback.
All reactions