Testing RXD and TXD Connections

Is there a way to test that the RXD and TXD pins are sending and receiving data on the nrf5340? I am trying to connect these pins to the u-blox ANT-B10-00C using male to female jumper cables but when I try this setup, my serial terminal is not outputting any data.

Parents Reply Children
  • I believe I have set everything up correctly. Below is part of my overlay file for uart2. I have the RX pin of the nrf5340 connected to the TX pin of the ANT-B10-00C and the TX pin of the nrf5340 connected to the RX pin of the ANT-B10-00C. However, when I set the communication up, nothing is being outputted to my serial terminal.

     

    This is the code I am trying to run: 

    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/uart.h>
    #include <zephyr/sys/printk.h>
    #include <string.h>
    
    #define UART_DEVICE_NODE DT_NODELABEL(uart2)  // Use UART2
    
    const struct device *uart_dev;
    
    int main(void) {
        uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);
    
        if (!device_is_ready(uart_dev)) {
            printk("ERROR: UART2 not ready!\n");
            return -1;  // Indicate error
        }
    
        printk("UART2 communication test started...\n");
    
        const char *test_msg = "Hello ANT-B10!\r\n";
    
        while (1) {
            // Send message to ANT-B10
            uart_fifo_fill(uart_dev, (const uint8_t *)test_msg, strlen(test_msg));
            printk("Sent: %s", test_msg);
    
            k_sleep(K_MSEC(100));  // Short delay
    
            // Check for response
            uint8_t buffer[32];
            int recv_len = uart_fifo_read(uart_dev, buffer, sizeof(buffer) - 1);
    
            if (recv_len > 0) {
                buffer[recv_len] = '\0';  // Null-terminate received data
                printk("Received from ANT-B10: %s", buffer);
            } else {
                printk("No response yet...\n");
            }
    
            k_sleep(K_SECONDS(2));  // Repeat every 2 seconds
        }
    
        return 0;  // Indicate success
    }
    
    

    Would you happen to know why nothing is happening in my terminal?

Related