This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Programming other NRF51822s using NRF51-DK

What is the pinout on the DEBUG OUT-pins? How do I adapt the code to work both with dev board and an external chip? There are BSP stuff I probably can't use that I use for testing, I guess these can be removed with #ifdefs

But what about the BOARD_PCA10028 define? Should this be omitted and it would just work on "bare" NRF51822s?

Thanks!

  • E.M.,

    The important pins you need on the DEBUG OUT connector are pins 1 through 5. Pin 1 is VTarg, Pin 2 is SWDIO, Pin 3 is GND, Pin 4 is SWCLK, Pin 5 is another GND. You must provide power to your target externally, the DEBUG OUT port does not supply it.

    As for board support, I usually just remove it from the run time environment completely if I can. Then you don't have to worry about the define and if you create your boards to be pin compatible with the nRF-DK kit it never comes up, and you can use the same executable for both target types.

    If you absolutely need that module and they're not pin compatible, I'd recommend making a separate target for whether you're building for the nRF51-DK board versus an external target. Go to Project->Manage->Components, Environment, Books... and create a new target. Call it whatever you'd like. Select your new target using the drop down menu next to your load key on the main window. Then go to the project settings and replace BOARD_PCA10028 with BOARD_CUSTOM. Then create a header file titled custom_board.h and place it somewhere the project will include from. From there you can follow the example from pca10028.h to name your pins properly in your new custom board file. The location of file pca10028.h depends on where you installed Keil, but it should be in ...\Keil\ARM\Pack\NordicSemiconductor\nRF_Examples\x.x.x\bsp, where x.x.x is the version of the SDK you're using. Now you can switch building for each target on the fly using the drop down menu whenever you want to switch between the nRF-DK and the external target. I would also recommend going into the Output tab in the project settings and naming the executables something different to make it easier to not download the wrong build type to the wrong board.

  • Thanks. I am using visual studio + GCC & Make. So I have full control over build configurations :)

    I will wrap the code in #ifdefs and add another build target for release with optimizations etc omitting all BSP stuff then. Glad to hear that it's all what it takes. I also assume that I can just use NRF Go studio to program softdevice as usual as I would have done it on the kit directly. As I read in the User Guide it can sense the voltage and seamlessly program the device connected to DEBUG OUT

    From where on the drawing does Pin 1 start by the way? www.nordicsemi.com/.../nRF51-DK.png

    Top left?

  • Yes, nRF Go Studio works just fine for programming softdevice, bootloader and application. Pin 1 on that drawing is bottom left corner, you can see the "1" right next to the P19 marking.

  • Thank you so much! I ordered 2x5 PCB socket that fits 1.27mm so I can solder on some cables that I can program devices with. Just to confirm it 100%. does it go to the right with pin 1-5, and then from right to left on the 2nd row? (it's mounted upside down it seems)

  • No, that's not how the pinout gets labeled on these guys (connector pinout vs IC pinout is something that makes my blood boil, personally). It goes across rows and then shifts. Going by the image in your previous comment, pin 1 is bottom left, pin 2 is top left, pin 3 is just right of pin 1, pin 4 is just right of pin 2 and also above pin 3, ect. Here's a link to another devzone question where a Nordic Employee posted schematic images: devzone.nordicsemi.com/.../. Personally I've found connecting pin 9 unnecessary, but you can attach it if you want.

Related