Page 1 of 1

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

Posted: Fri Oct 05, 2018 6:15 pm
by WhiteHare
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.

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

Posted: Thu Oct 11, 2018 2:34 am
by WhiteHare
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.

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

Posted: Thu Oct 11, 2018 9:35 am
by kak
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

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

Posted: Thu Oct 11, 2018 10:55 am
by kak
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

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

Posted: Thu Oct 11, 2018 2:45 pm
by WhiteHare
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.