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

How to control nordic uart to other microcontroller?

Hi forum,

I am working on nrf52832, using sdk 15.0.0. I want to send the data(command) from esp32 to nRF52832 through Rx ,Tx . I have done connections rx,tx,gnd . I can't able to transmit and receive the data why ? i have used ble_app_uart examples , i didn't change anything , just included one data to print .

nRF52832           esp32

8  pin Rx----->    Tx 17pin

9 pin  Tx ------>   Rx 16pin

please someone help me to slove this problem.

Parents
  • Hi there,

    Are you using a custom board? Are you able to run the example with loopback test?

    regards

    Jared 

  • thanks for reply,

    yes, I am using custom board.

    I am tried using loopback test still not able to send or receive data via uart.

    please help me.

  • dewal said:

    I am tried using loopback test still not able to send or receive data via uart.

    On second thought, Loopback test might not be the appropriate test to find the issue in your case. Let's go back to your original test setup:

     

    I am working on nrf52832, using sdk 15.0.0. I want to send the data(command) from esp32 to nRF52832 through Rx ,Tx . I have done connections rx,tx,gnd . I can't able to transmit and receive the data why ? i have used ble_app_uart examples , i didn't change anything , just included one data to print .

     Could you use either a oscilloscope or a logical analyzer and see if any data is sent on the TX or RX lines?

    regards

    Jared 

  • thanks for reply,

    I am checked through original code(without loopback) on logic analyzer.

    tried to send single character but not received. Waveform not generated on logic analyzer.

  • hi forum,

    please help me slove this problem.

    Is their any TTL to USB convertor  required?(for priniting data on putty)

    1. Can you use the debugger and see if the program asserts? 
    2. Can you share the modified example.
    1. Can you use the debugger and see if the program asserts? 

    Yes, please check this 

    please check below code ,

    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "app_uart.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "nrf.h"
    #include "bsp.h"
    #include "nrf_uart.h"
    
    
    #define UART_TX_BUFF_SIZE 128 // TX buffer size
    #define UART_RX_BUFF_SIZE 128 // RX Buffer size
    
    
    #define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
    
    
    // A simple error handler for uart if something goes wrong...
    void uart_err_handle(app_uart_evt_type_t * p)
    {
      
    }
    
    
    
    int main(void)
    {
      uint32_t err_code; // a variable to hold the error value
    
      bsp_board_init(BSP_INIT_LEDS); // initialize leds
    
    
      const app_uart_comm_params_t com_params = // struct to hold the uart configurations
      {
        RX_PIN_NUMBER, 
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        UART_HWFC, // hardware flow control disabled
        false, // parity = none
        NRF_UART_BAUDRATE_115200 // set this baud rate for communication
    
      };
    
    // pass all the values to this function to initialize the UART module
     APP_UART_FIFO_INIT(&com_params, UART_RX_BUFF_SIZE, UART_TX_BUFF_SIZE, uart_err_handle, APP_IRQ_PRIORITY_LOWEST, err_code);
    
    
      APP_ERROR_CHECK(err_code); // check if everything initialized correctly
    
    // Print a start msg over uart port
      printf("Hello PC from nordic Device!!\r\n");
    
      while(true)
      {
        uint8_t cr; // create a variable to hold the UART char data
    
        while(app_uart_get(&cr) != NRF_SUCCESS); // wait here until it receives a char from pc
    
        if(cr == 't') // check if the received char is t
        {
        bsp_board_leds_on(); // turn on all the leds
        printf("Leds Turned On!!\r\n"); // print out the state of leds
        }
    
        if(cr == 'k') // check if the received chart is k
        {
        bsp_board_leds_off(); // turn off all the leds
        printf("Leds Turned off!! \r\n"); // print out the state of leds
    
        }
    
    
        } // while loop closed
    
    
       
    } // main function closed
    
    
    /** @} */
    

    Is their any code for reference of UART on nrf52832.

Reply
    1. Can you use the debugger and see if the program asserts? 

    Yes, please check this 

    please check below code ,

    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "app_uart.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "nrf.h"
    #include "bsp.h"
    #include "nrf_uart.h"
    
    
    #define UART_TX_BUFF_SIZE 128 // TX buffer size
    #define UART_RX_BUFF_SIZE 128 // RX Buffer size
    
    
    #define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
    
    
    // A simple error handler for uart if something goes wrong...
    void uart_err_handle(app_uart_evt_type_t * p)
    {
      
    }
    
    
    
    int main(void)
    {
      uint32_t err_code; // a variable to hold the error value
    
      bsp_board_init(BSP_INIT_LEDS); // initialize leds
    
    
      const app_uart_comm_params_t com_params = // struct to hold the uart configurations
      {
        RX_PIN_NUMBER, 
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        UART_HWFC, // hardware flow control disabled
        false, // parity = none
        NRF_UART_BAUDRATE_115200 // set this baud rate for communication
    
      };
    
    // pass all the values to this function to initialize the UART module
     APP_UART_FIFO_INIT(&com_params, UART_RX_BUFF_SIZE, UART_TX_BUFF_SIZE, uart_err_handle, APP_IRQ_PRIORITY_LOWEST, err_code);
    
    
      APP_ERROR_CHECK(err_code); // check if everything initialized correctly
    
    // Print a start msg over uart port
      printf("Hello PC from nordic Device!!\r\n");
    
      while(true)
      {
        uint8_t cr; // create a variable to hold the UART char data
    
        while(app_uart_get(&cr) != NRF_SUCCESS); // wait here until it receives a char from pc
    
        if(cr == 't') // check if the received char is t
        {
        bsp_board_leds_on(); // turn on all the leds
        printf("Leds Turned On!!\r\n"); // print out the state of leds
        }
    
        if(cr == 'k') // check if the received chart is k
        {
        bsp_board_leds_off(); // turn off all the leds
        printf("Leds Turned off!! \r\n"); // print out the state of leds
    
        }
    
    
        } // while loop closed
    
    
       
    } // main function closed
    
    
    /** @} */
    

    Is their any code for reference of UART on nrf52832.

Children
Related