[nRF52] How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

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
User avatar
WhiteHare
Posts: 80
Joined: Thu Oct 04, 2018 4:00 am

[nRF52] How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

Post by WhiteHare » Fri Oct 05, 2018 6:15 pm

I was (I think) able to flash the nRF52840-DK micropython build onto the NnRF52840-DONGLE, but now I can't communicate with the dongle because the exposed pins on the dongle are different from the default serial pins on the DK. Furthermore, the chip based USB on the dongle no longer works because, I presume, the DK doesn't need that.

Therefore, how do I change the RXI and TXO serial pin assignments in the nRF52840 micropython build? :?: In theory, any GPIO pin can be assigned those roles.
Last edited by WhiteHare on Thu Oct 11, 2018 5:32 pm, edited 1 time in total.

User avatar
WhiteHare
Posts: 80
Joined: Thu Oct 04, 2018 4:00 am

Re: How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

Post by WhiteHare » Thu Oct 11, 2018 2:34 am

I found an alternative dongle which may be a workaround to this dilemma:
https://www.tindie.com/products/Zelin/n ... sb-dongle/
Price is $3 more than Nordic dongle, but the selling point for me is that, unlike the Nordic dongle, it exposes pins P0.06 and P0.08, which are used by the nRF52840DK for UART communications.

kak
Posts: 17
Joined: Fri Oct 05, 2018 11:35 am

Re: How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

Post by kak » Thu Oct 11, 2018 9:35 am

If I had to guess, I'd say that the pin configuration of the uart is in micropython/ports/nrf/boards/pca10056/mpconfigboard.h

Code: Select all

// UART config
#define MICROPY_HW_UART1_RX         (8)
#define MICROPY_HW_UART1_TX         (6)
#define MICROPY_HW_UART1_CTS        (7)
#define MICROPY_HW_UART1_RTS        (5)
#define MICROPY_HW_UART1_HWFC 	    (1)
The numbers there match the pin numbers (of port P0) in the DK schematic.
https://www.nordicsemi.com/eng/nordic/d ... 855/144860

kak
Posts: 17
Joined: Fri Oct 05, 2018 11:35 am

Re: How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

Post by kak » Thu Oct 11, 2018 10:55 am

Seems to be right, the pins are being set in ports/nrf/modules/machine/uart.c:

Code: Select all

    nrfx_uart_config_t config;
    .
    .
    config.pseltxd = MICROPY_HW_UART1_TX;
    config.pselrxd = MICROPY_HW_UART1_RX;
nrfx_uart_config_t config is from the nrf52 SDK: https://infocenter.nordicsemi.com/topic ... 9_0_28_1_2

User avatar
WhiteHare
Posts: 80
Joined: Thu Oct 04, 2018 4:00 am

Re: How do I change the RXI and TXO serial pin assignments in the nRF52840 build?

Post by WhiteHare » Thu Oct 11, 2018 2:45 pm

Nice! Seems like it's worth a shot. If that doesn't work, then (per your other post) soldering directly to the UART Tx and Rx pins (the ones now populated with LEDs, as you pointed out) sounds very promising and, I think, will likely work. :D When I find the time, I'll give it a try.

On a related note, if I can just find a way to directly manipulate the nRF52 registers (as would be easy in C but, apparently, somewhat exotic and obscure in micropython), I could change the UART pin assignments that way, as it's all explained in the datasheet. I've done it in C, but, as simple as it should be, I haven't figured out how to do it yet in micropython. I'd settle for a simple PEEK and POKE equivalent, if there were such a thing. When it comes to nRF52, those are the keys to the kingdom.

Post Reply