[nRF51822/...] Complete hardware/development tutorial?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
beginner
Posts: 2
Joined: Fri Dec 21, 2018 8:55 am

[nRF51822/...] Complete hardware/development tutorial?

Post by beginner » Fri Dec 21, 2018 10:02 am

Hello,
I am very new to microcontrollersin general. I started a few weeks ago with buying a NodeMCU ESP8266 board and just following the great official guide: http://docs.micropython.org/en/latest/e ... neral.html
I did not have any experience with electronic or microcontrollers, but with this guide and all the information on the internet I feel confident on being able to create a lot of cool projects with ESP8266 now. Even with bare ESP8266 it should be easily possible for me to add for example a serial to USB adapter to it and develop some stuff. If MicroPython and all the excellent guides wouldn't exists I would probably never become interested in microcontrollers.

Now I am looking at the nRF51/52 microcontrollers and it is hard for me to find the resources which will get me up the speed quickly.
For example if I buy this chip https://de.aliexpress.com/item/1pc-Nord ... afd4a8b3-7 how can I start developing MicroPython applications with it. Obviously I can not just plug it into one of the USB ports of my PC and run some commands as for NodeMCU.

Does anyone know whether somewhere I complete guide exists that explains how I would go from buying this chip to developing some application for it, just like i would for ESP8266?


Best regards,
Tim

User avatar
rdagger
Posts: 79
Joined: Tue Feb 28, 2017 6:16 pm
Contact:

Re: [nRF51822/...] Complete hardware/development tutorial?

Post by rdagger » Wed Jan 02, 2019 3:38 am

The Adafruit Feather nRF52840 Express should be released soon. They will probably include a CircuitPython tutorial.

c45713
Posts: 27
Joined: Fri Dec 09, 2016 7:09 pm

Re: [nRF51822/...] Complete hardware/development tutorial?

Post by c45713 » Wed Jan 02, 2019 9:49 pm

Hi Tim,

I guess most of the cheap modules will do as long as you have a programmer available. I see in the forum that ST-Link v2 should work:
viewtopic.php?f=12&t=5011&p=29064. Personally i use an external J-Link programmer or a development kit with on-board debugger/flasher.

I'm not sure on what level you want to get quickly started, but assuming its from receiving the module in the mailbox and up to a REPL over UART, i'll give it a try:
  1. Select a template to use from the boards folder that targets the specific variant of the chip. In this case it is the 16k RAM or 32K RAM variant, its hard to tell what you will get :) In any case, it could the pca10000/pca10001/microbit/wt51822_s4at for the 16K variant and pca10028/pca10031 for the 32K variant.
  2. Modify the mpconfigboard.mk to align with the pins you select for UART and disable LED. In this case i could think of something like this:

    Code: Select all

    #define MICROPY_PY_MACHINE_UART     (1)
    #define MICROPY_PY_MACHINE_I2C      (1)
    #define MICROPY_PY_MACHINE_HW_SPI   (0)
    #define MICROPY_PY_RANDOM_HW_RNG    (0)
    #define MICROPY_MBFS                (0)
    #define MICROPY_HW_HAS_LED          (0)
    #define MICROPY_HW_UART1_RX         (9)
    #define MICROPY_HW_UART1_TX         (11)
    #define MICROPY_HW_UART1_HWFC       (0)
    
    UART is now configured to Pin 0.09 and 0.11, Leaving Pin 0.00 (AREF0) and 0.01 (AIN2) free for GPIO/I2C or ADC as these pins has special properties for ADC which 0.09/0.11 does not.
  3. Now, do a compilation using this modified board (you can always create a new folder containing the same files as the template you based it on and point to the folder name as target). 'make BOARD=myboardfolder', or if modified an existing board target like pca10001, 'make BOARD=pca10001".
  4. Next up is flashing. This is a bit dependent on what flasher you have available. The default flasher in the port is Jlink, using nrfjprog from Nordic Semiconductor to make the flashing a bit more easy. If using a DAP-link or similar the port also provides flash target using pyocd/OpenOCD. This can be modified to be the default board flasher by modifying the mpconfigboard.mk and add a FLASHER entry, like the microbit target has: https://github.com/micropython/micropyt ... oard.mk#L9
    If not configured by the mpconfigboard.mk it can also be supplied through a flag to Make, by setting FLASHER=pyocd etc.
    For flashing the compiled target the following command can now be issued, along with the target board flag in order to know which of the multiple target you might have compiled to flash. 'make BOARD=pca10001 flash" or 'make BOARD=myboard FLASHER=pyocd flash". The flasher should be hooked onto the debug pins VDD/SWDIO/SCLK/GND pins. In most cases the programmers does not supply any current to the device, only programming logic, so most probably you will have to also feed the device with 3V while flashing.
  5. Last, wire the USB->UART adapter to the Pin 0.09 and 0.11 to get UART rx/tx. I guess most of these UART to USB adapters uses TTL level around 3V.
  6. For more experiments enabling Bluetooth i believe what is needed is sufficently described over here::
    https://github.com/micropython/micropyt ... ooth-stack
I would also like add a personal recommendation to take a look at nrf52 targets over nrf51 as they tend to be a bit more fun to play with as they provide more RAM and FLASH and not hit stack/flash overflow too much :)

Hope this was to some help,
Glenn

beginner
Posts: 2
Joined: Fri Dec 21, 2018 8:55 am

Re: [nRF51822/...] Complete hardware/development tutorial?

Post by beginner » Thu Jan 03, 2019 9:45 am

Thank you both!

I will try your suggestions and I am going to update this post as soon as I receive my modules on how it went :)

Post Reply