This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Converting code for micro:bit v1 (nRF51822) to micro:bit v2 (nRF52833)

1_gpio.zip2_uart.zip3_gpiote.zip4_twi.zip

Hello,

I am a research assistant at the Norwegian University of Science and Technology. We have in the past been using the micro:bit v1 for our practical labs which purpose is to introduce the students to basic C programming. For that, we have been using GCC ARM as our compiler, nrfjprog to flash compiled code to the micro:bit, and lastly JLink to communicate with the micro:bit. The latter removes the DAL by just simply drag and drop of the hex file from Segger.com.

Our problem is that for this year, we have received the second version of the micro:bit, which uses a nrf52833. I was therefore wondering if there is someone who could help me on the way to replicate the simple assignments that we have earlier created for the v1 for the new v2?

I attached the solutions for micro:bit v1 as a zip file, with the Makefile required to run it. The code runs by going into each folder, and then compile with "make", before one can flash over the compiled program with "make flash". Here is a small description on what each code does:

  1. 1_GPIO programs the micro:bit v1 to turn on and off the LEDs in the matrix with the A/B button.
  2. 2_UART programs the micro:bit v1 for two ways communication. In our lab, we use picocom.
  3. 3_GPIOTE programs the micro:bit v1 to define events (button B pressed),  and 3 tasks (turn off and on the voltage to the three LEDs matrices)
  4. 4_TWI programs the micro:bit v1 to connect to the gyro so that the LED matrix can be used to describe the orientation of the micro:bit.

Ultimately, what we desire is to have something similar. Ideally a Makefile, a .build_system folder, and .c/h files.

What I have done untill now is to recreate the first assignments with GPIO, but the micro:bit does not seem to respond. I tried to install the new firmware for the micro:bit v2 for JLink but I suspect I have to modify the .build_system folder and the Makefile (I suspect one only needs to change the nrf51->nrf52 and set the cortex to 4?) accordingly.

Best wishes,

Kiet

Parents
  • Hi,

    A few tips:

    1. You should replace the system and startup files with the system_nrf52833.c/h and gcc_startup_nrf52833.S, not with *nrf52* files (these are for nRF52832). You can find the files in the latest MDK.
    2. Change the CPU type to Cortex M4 (and optionally enable hard float support, but that is likely not needed for you projects).
    3. Increase the Flash and RAM lengths in your linker script to match the sizes of the nRF52833.
    4. Verify that all used peripheral are located at the base address defined in your applications, see Instantiation. You should also check the register documentation for each peripheral that is used, to make sure no registers have been moved or removed. This step would have been simpler if you had used the header files from the MDK (e.g. nrf52833.h) instead of defining the registers in the applications.
    5. Check that the GPIOs that are used by application match the schematics of the micro:bit 2. The nRF52833 have two GPIO ports, so some GPIOs needs remapping to match the connected peripherals.

    Hope this helps you run your examples on the micro:bit v2.

    Best regards,
    Jørgen

  • Hey Jørgen,

    I have been playing around with the system and I have some questions regarding some of your points:

    1. When I replace my system and startup files with the related nrf52833 variant, I have some dependencies. Do you know which ones are relevant for my use case (only basic manipulation of GPIO and some of the peripherals). I see that system_nrf52833.c is including nrf52.c, which again includes several nrf and nrf52 specific libraries: do you think is needed?
    2. Thanks for this tip!
    3. Just to verify since I am relatively new to embedded: I looked at the memory mapping of both the nRF52833 and the nRF51822, and it seems to be that they are similar where both have->
      1. MEMORY
      2. {   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000
      3.     RAM (rwx) : ORIGIN =   0x20000000, LENGTH = 0x400
      4. }
    4. Thanks for the this tip!
    5. So the difference between P1.xx and P0.xx is if the base adress is at 0x50000000 vs 0x50000000 and 0x50000300 right? 

    Lastly sorry for so many questions, I am still learning together with the students :)

    Best wishes,

    Kiet

Reply
  • Hey Jørgen,

    I have been playing around with the system and I have some questions regarding some of your points:

    1. When I replace my system and startup files with the related nrf52833 variant, I have some dependencies. Do you know which ones are relevant for my use case (only basic manipulation of GPIO and some of the peripherals). I see that system_nrf52833.c is including nrf52.c, which again includes several nrf and nrf52 specific libraries: do you think is needed?
    2. Thanks for this tip!
    3. Just to verify since I am relatively new to embedded: I looked at the memory mapping of both the nRF52833 and the nRF51822, and it seems to be that they are similar where both have->
      1. MEMORY
      2. {   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000
      3.     RAM (rwx) : ORIGIN =   0x20000000, LENGTH = 0x400
      4. }
    4. Thanks for the this tip!
    5. So the difference between P1.xx and P0.xx is if the base adress is at 0x50000000 vs 0x50000000 and 0x50000300 right? 

    Lastly sorry for so many questions, I am still learning together with the students :)

    Best wishes,

    Kiet

Children
No Data
Related