Receive data via uart with nrf5340

hello, I am currently working on a project that involves sending data via serial from a device to the nordic nr5340.

but I can't find an example that shows how it would be in this case, in the course it tells me to use the asynchronous api, but in this case it is to enter the parameters in the console, so I would like you to please tell me an example so that I can make the configuration.

Currently what I know is that a configuration must be made to specify the pins since by default the nrf5340 receives is through the gpios that are connected to the usb, however in the case of how the data is handled it is still confusing for me

So could you please tell me where to start.

Parents Reply Children
  • hello, thanks for the reply and sorry for the delay in responding, well What I really want to do is the following:

    1) I have a sensor that sends the following numerical data through uart:

    2) What I want to do is use one of the sdk apis, preferably the asynchronous one that is the one I use in the course to be able to access that data using the nrf5340.

    Currently I already managed to configure so that the rx and tx pins are in the gpio P1.14 and P1.15 respectively, and I have them connected, and I tried the connection and the interface indicates that it is online.

    However, what is not clear to me is how to receive the data, so I would like to know if there is not a simple example with that api for this type of case.

    I am new to using the device and any information you can provide me would be greatly appreciated.

  • Hi brando, I will get back to you after the weekend.

  • Have you tried running the example from Lesson 5 of the devacademy course? You could try to printing rx_buf.

    There is also another sample demonstrating asynchronous UART. Please note that sample was tested using nRF Connect SDK v1.9.1. I suggest testing it using v1.9.1 before migrating it to v2.x.x.

  • hello greetings, I have been using that example as a base, but from what I understand is that this example is to be used with the console, and I do not fully understand how it would be for my case, since I currently have the following:

    1) I have 1 pcb connected via serial to nordic via pins 14 and 15, using the following configuration in my overlay file.

    &uart1 {
    		compatible = "nordic,nrf-uarte";
    		reg = <0x8000 0x1000>;
    		interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
    		status = "okay";
    		current-speed = <115200>;
    		pinctrl-0 = <&uart1_default>;
    		pinctrl-1 = <&uart1_sleep>;
    		pinctrl-names = "default", "sleep";
    };
    
    &uart1_default {
    		group1 {
    				psels = <NRF_PSEL(UART_TX, 1, 14)>;
    
    		};
    		group2 {
    				psels = <NRF_PSEL(UART_RX, 1, 15)>;
    			
    		};
    };
    &uart1_sleep {
    		group1 {
    				psels = <NRF_PSEL(UART_TX, 1, 14)>,
    				        <NRF_PSEL(UART_RX, 1, 15)>;					
    		
    		};
    };
    


    2) I am using the course example as a base, but I don't understand how to get the data, nor how to manipulate it. I know that in the callback function it tells me that I can access it but I don't understand how it does it and I would really like to have more clarity on that aspect.

Related