This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to Map UARTE to physical pins?

Hello,

I am a newby to the nRF5340 and Zephyr and I am stuck. I would like to know how to map physical pins to a particular UARTE.

I have read in the user manual OPS_v0.6.1 that this can be configured using these registers PSEL.RXD, PSEL.CTS, PSEL.RTS and PSEL.TXD but I am not sure how.

Is there a tutorial or a sample example where this is illustrated?

Thank you.

  • Hello!

    When mapping physical pins in Zephyr you can use overlay files. For example, if you want to map the UARTE of the application processor of the nRF5340 on the PDK do the following:
    - Make a file in your project directory called: nrf5340pdk_nrf5340_cpuapp.overlay
    - Fill it with the following code: 

    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	tx-pin = < 0x14 >;
    	rx-pin = < 0x16 >;
    	rts-pin = < 0x13 >;
    	cts-pin = < 0x15 >;
    };


    You can see how it's done for the nRF52840 DK here and you can read more about the Devicetree overlays here.

    Hope this helps!

    Best regards,
    Carl Richard

  • Thank you Carl.

    It is now clear to me how to go about it.

    So, what is meant by the following description I read in the user manual OPS_v0.6.1, section 7.38.8?

    7.38.8 Pin configuration
    The different signals RXD, CTS (Clear To Send, active low), RTS (Request To Send, active low), and TXD
    associated with the UARTE are mapped to physical pins according to the configuration specified in the
    PSEL.RXD, PSEL.CTS, PSEL.RTS, and PSEL.TXD registers respectively.

    Thank you again.

  • Hello again!

    Good to hear!

    These registers are configured through Zephyr's Devicetree overlays. I suggest that your read chapter 1.4 The Device Tree from part 2 of our nRF Connect SDK tutorial, where these concepts are well explained!

    Best regards,
    Carl Richard

  • Thank you Carl for your prompt response.

    I have gone through the tutorial. It covers the Device Tree concept in section 1.4 but nothing on how to use the registers PSEL.RXD, PSEL.CTS, PSEL.RTS, and PSEL.TXD to map the different signals (RXD, CTS...), to physical pins.

    I, however, do understand how to use the .overlay file to map the different signals (RXD, CTS...), to physical pins as you explained in your previous reply.

    Kind regards

    Mohamed

  • Hi again, Mohamed.

    It is not explained explicitly in the tutorial, but it does show how the .overlay files are translated into #defines which in turn are used by the drivers(where the registers you mention are set). You can access the registers directly as well, as hinted to by our documentation. However, I recommend using the .overlay files, as mentioned.

    Best of luck,
    Carl Richard

Related