Question about uart configurations for nRF52832 and nRF52840

Dear ,

I am currently testing the UART peripheral on nRF52832 and nRF52840 using nRF Connect SDK.

Basically, I have a sensor that continues sending out data via uart and I would like to use the uart peripheral to receive and parse the data packets. I checked the sample code provided as lpuart, but still have a few questions.

In the devicetree setup for the uart, there are REQ pin and RDY pin. Are these pins always compulsory for using lpuart? Can I use uart without configure these two pins, i.e. using only tx and rx pins?

As to the application I mentioned above, how can I set up an interrupt-driven process which will analyze each incoming byte once it's received?

If you could kindly provide a few advice and directions, it will be very helpful.

Thank you so much for your help and assistance.

Kind regards, Kevin

Parents
  • In the devicetree setup for the uart, there are REQ pin and RDY pin. Are these pins always compulsory for using lpuart?

    Yes, these are used to start and stop the UART to ensure low power when there is no UART data.

    Can I use uart without configure these two pins, i.e. using only tx and rx pins?

    Sure, but then it's not low power since the UART needs to be enabled continously to ensure it can receive data at any time.

    As to the application I mentioned above, how can I set up an interrupt-driven process which will analyze each incoming byte once it's received?

    It is not recommended to analyze each incomming bytes, it will be very CPU intensivice, for instance it will take time to call the interrupt handler for each byte. Instead common practise is to define multiple buffers, and then when a buffer is full and/or there is a configruable timeout since the last bytes was received, then the uart handler will be called.

    Best regards,
    Kenneth

Reply
  • In the devicetree setup for the uart, there are REQ pin and RDY pin. Are these pins always compulsory for using lpuart?

    Yes, these are used to start and stop the UART to ensure low power when there is no UART data.

    Can I use uart without configure these two pins, i.e. using only tx and rx pins?

    Sure, but then it's not low power since the UART needs to be enabled continously to ensure it can receive data at any time.

    As to the application I mentioned above, how can I set up an interrupt-driven process which will analyze each incoming byte once it's received?

    It is not recommended to analyze each incomming bytes, it will be very CPU intensivice, for instance it will take time to call the interrupt handler for each byte. Instead common practise is to define multiple buffers, and then when a buffer is full and/or there is a configruable timeout since the last bytes was received, then the uart handler will be called.

    Best regards,
    Kenneth

Children
  • Dear Kenneth,

    Yes. I think what I need here is a normal uart instead of a low power uart.

    Is there a sample code for uart in nRF Connect SDK as well, as I only saw lpuart Zepthyr example so far? How could I adapt the lpuart example as it can't compile if the device tree overlay taken out from the sample is changed as below, i.e. commented lpuart ?

    /* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */
    
    &uart0 {
    	rx-pin = <22>;
    	tx-pin = <23>;
    	/delete-property/ rts-pin;
    	/delete-property/ cts-pin;
    	compatible = "nordic,nrf-uarte";
    
    	/*
    	lpuart: nrf-sw-lpuart {
    		compatible = "nordic,nrf-sw-lpuart";
    		status = "okay";
    		label = "LPUART";
    		req-pin = <24>;
    		rdy-pin = <25>;
    	};
    	*/
    };
    
    &gpiote {
    	interrupts = <6 NRF_DEFAULT_IRQ_PRIORITY>;
    };
    

    Thanks a lot for your help.

    Kind regards, Kevin

Related