UART unable to confiogure

Please refer screen shot attach
I am able to configure uart0 but not able to configure uart1,2,3

i am receiving multiple errors while same code is working fine for uart0.

I am using zephyre OS , 

i am using latest nrf Connect SDK 2.7.0

H/W nrf52840dk/nrf52840.




refer sample code


#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/sys/printk.h>

#define SLEEP_TIME_MS 1000

const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(uart1));

static uint8_t tx_buf[] =   {"SLS TEST Validation ==nRF Connect SDK Fundamentals Course\r\n"
                             "1 TO 100 kit\r\n"};

//static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data);

int main(void) {
    int ret;
if(!device_is_ready(uart)){
    printk("UART Device not Ready\r\n");
    return 1 ;
    }
 while (1) {

       
ret = uart_tx(uart, tx_buf, sizeof(tx_buf), SYS_FOREVER_US);
    if(ret){
        return 1;
    }
k_msleep(SLEEP_TIME_MS);
    }
    return 0;
}
Parents Reply
  • Hi,

     

    Glad to hear that you got it working!

    If you want to change the pins, you can ask the AI, in the lower right corner.

    For instance "show me how to change pins on uart1", and it'll give you a device tree overlay showing something like this:

    &pinctrl {
       uart1_default_alt: uart1_default_alt {
          group1 {
             psels = <NRF_PSEL(UART_TX, 0, 14)>,
                     <NRF_PSEL(UART_RX, 0, 16)>;
          };
       };
       /* required if CONFIG_PM_DEVICE=y */
       uart1_sleep_alt: uart1_sleep_alt {
          group1 {
             psels = <NRF_PSEL(UART_TX, 0, 14)>,
                     <NRF_PSEL(UART_RX, 0, 16)>;
             low-power-enable;
          };
       };
    };
    
    &uart1 {
      pinctrl-0 = <&uart1_default_alt>;
      /* if sleep state is not used, use /delete-property/ pinctrl-1; and
       * skip the "sleep" entry.
       */
      pinctrl-1 = <&uart1_sleep_alt>;
      pinctrl-names = "default", "sleep";
    };

    Change this to the GPIO that you wanted.

     

    Kind regards,

    Håkon

Children
No Data
Related