Creating nRF51x22 Embedded Targets

In my previous post I demonstrated the use of a Free Pascal embedded target for the nRF52832 Nordic Semiconductor SoC processor.  This chip also has a little brother, the nRF51422 and it’s variant the nRF51822.  Unfortunately, they aren’t currently supported as embedded targets by Free Pascal.  So I have returned to looking into the feasibility of implementing them.

Last year, I asked about support for these chips on the Free Pascal mailing list and was kindly created a patch by Michael Ring giving provisional support for them.  Unfortunately, I ran out of time to work on this and in the meantime the Nordic Semiconductor SDK and Free Pascal have gone through several version changes.

Ideally, the current processor SVD should be used to generate new support files, but to get up and running as quickly as possible, I have adapted Michael’s original patch to work with  Free Pascal trunk and structured it consistently with the new nRF52832 support.

I have also adapted my demo for the nRF52832 to run on the nRF51422 and tested it with my the nRF51-DK.  The only change to the source code is to the pin numbers of the board’s LEDs.  The build setup is identical to that of the nRF52-DK, with only minor changes to the flashing script:

nrfjprog --recover -f NRF51
nrfjprog --program Test.hex --verify --chiperase -f NRF51
nrfjprog --rbp ALL -f NRF51
nrfjprog -r -f NRF51

The new last line forces a reset for the board, which happens automatically on the nRF52-DK, but not with the nRF51-DK.  To use this program within the Lazarus IDE the custom project options need to be set to:


Otherwise this behaves identically to the nRF52832 version.  The test program is available here and the experimental patch for Free Pascal here.  Hopefully, I will be able to develop this into a stable solution for supporting these targets with the help of the excellent Free Pascal developer community.

Leave a Reply