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

connect to the nRF52840-DK with the STM32F103 development board

Hi, recently I want to establish a connection between two development boards (STM32F103 + nRF52840-DK), that the STM32f103 board can create the data and send it to the nRF52840-DK, the openwsn has been ported to the nRF52840-DK. I want to combine development boards and Component wireless sensor networks. But I find that the nRF52840-DK has only one usart port pin(reference datasheet), If there has the other UARTport I don't find, please correct me. So I want to use other communication protocols (like I2C and SPI, etc). But I am not familiar with 52840 programming, I hope I can provide some help.

Parents
  • the nRF52840 has 2 UART. The reason why you don't see a specific pin for it is because any gpio pin can be used for it.  You see only 1 uart pin on the DK because it is being used and connected to the onboard jlink. The 2 uart is not used therefore not mapped anywhere. 

  • Thanks, I have found the definition of the serialization_application_board. If I can use this port to implement UART communication? 

  • In the file nrf_gpio.h, I don't find the definition of UART1, can I use the UARTE1 as UART?

  • Hello,

    kyh-ly said:
    In the file nrf_gpio.h, I don't find the definition of UART1, can I use the UARTE1 as UART?

    I do not understand your question here - are you looking for the *_UART* definitions? If so, they are located in your sdk_config.h file.
    I would not expect to find any UART related defines or functions in the nrf_gpio.h file, since this is the HAL for the GPIO peripheral.

    Please do not hesitate to ask if anything still should be unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

  • I want to use the UART1 to transmit the data from my board, and I can not find any useful instructions on how to configure UART1. below is another people code that configuring the UART0 by directly accessing the register(I can not confirm if right). I also want to configure uart1 using the register.

    void uart_init(){

    NRF_P0->OUTSET = 1 << UART_TX_PIN;//Set UART pin number bits in GPIO port

    // tx pin configured as output
    NRF_P0->PIN_CNF[UART_TX_PIN] = \
    ((uint32_t)GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)
    | ((uint32_t)GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
    | ((uint32_t)GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
    | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
    | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);

    // rx pin configured as input // 执行的就该函数是 nrf_gpio_cfg_input()-->nrf_gpio_cfg
    NRF_P0->PIN_CNF[UART_RX_PIN] = \
    ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
    | ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
    | ((uint32_t)GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
    | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
    | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);

    // configure uart

    NRF_UART0->BAUDRATE = (uint32_t)(UART_BAUDRATE_115200);
    NRF_UART0->CONFIG =
    (uint32_t)(UART_CONFIG_PARITY << UART_CONFIG_PARITY_POS)
    | (uint32_t)(UART_CONFIG_HWFC << UART_CONFIG_HWFC_POS);
    NRF_UART0->PSEL.RXD = (uint32_t)UART_RX_PIN;
    NRF_UART0->PSEL.TXD = (uint32_t)UART_TX_PIN;

    // enable UART rx done ready and tx done ready interrupts

    NRF_UART0->INTENSET =
    (uint32_t)(1<<UART_INTEN_RXDRDY_POS)
    | (uint32_t)(1<<UART_INTEN_TXDRDY_POS);

    // set priority and enable interrupt in NVIC
    NVIC_SetPriority(UARTE0_UART0_IRQn, NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY);

    NVIC->ISER[((uint32_t)UARTE0_UART0_IRQn)>>5] =
    ((uint32_t)1) << ( ((uint32_t)UARTE0_UART0_IRQn) & 0x1f);

    // enable uart
    NRF_UART0->ENABLE = (uint32_t)UART_ENABLE_ENABLE_Enabled;

    // start to tx and rx
    NRF_UART0->TASKS_STARTTX = (uint32_t)1;
    NRF_UART0->TASKS_STARTRX = (uint32_t)1;}

  • Hello again,

    kyh-ly said:
    I want to use the UART1 to transmit the data from my board, and I can not find any useful instructions on how to configure UART1.

    Have you seen the UART peripheral hardware example from the SDK
    It demonstrates how you could use the UART peripheral, and how to configure which UART instance you will be using in the sdk_config file.

    kyh-ly said:
    below is another people code that configuring the UART0 by directly accessing the register(I can not confirm if right)

    Where did you find this code? I would recommend that you make use of the supplied UART drivers, or app uart library, rather than working with the peripheral's registers directly. Especially if you are not comfortable with working at the register level.

    Best regards,
    Karl

  • Thank you, The first thing I must to do is familiar with the SDK and the hardware.

Reply Children
  • Hello again,

    Yes, this is an excellent idea. The nRF5 SDK's examples demonstrates a lot of the features available to the nRF device series, and how you may go about using them. I recommend starting with a non-BLE example ( such as the UART example I linked in my previous reply ), to get familiar with the peripheral, and then moving on to one of the examples that include BLE ( Such as the ble_app_uart examples ).

    Please do not hesitate to open a new ticket on the forum if you should encounter any issues or questions!

    Best regards,
    Karl

  • I want to know how to specify the specific configuration of the UART1. I always configure the UART0 and the UART1 doesn't work.Which files should I modify.

    void uart_init(){

    const app_uart_comm_params_t comm_params =
    {
    SER_APP_RX_PIN,SER_APP_TX_PIN,
    SER_APP_RTS_PIN,SER_APP_CTS_PIN,
    /*RX_PIN_NUMBER,
    TX_PIN_NUMBER,
    RTS_PIN_NUMBER,
    CTS_PIN_NUMBER,*/
    UART_HWFC,
    false,
    #if defined (UART_PRESENT)
    NRF_UART_BAUDRATE_115200
    #else
    NRF_UARTE_BAUDRATE_115200
    #endif
    };

    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_error_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);

    APP_ERROR_CHECK(err_code);

    }

  • kyh-ly said:
    I want to know how to specify the specific configuration of the UART1.

    Depending on what you would like to configure, it is either done in sdk_config or during the initialization.

    kyh-ly said:
    I always configure the UART0 and the UART1 doesn't work.Which files should I modify.

    The UART instance is configured in your sdk_config file, and the global instance should be initialized at the beginning of your main file.
    What is your UART configurations in sdk_config?

    Best regards,
    Karl

  • Same as sdk_config.h provided in the UART example.

    //UARTE configure

    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 1
    #endif
    // <o> NRFX_UARTE0_ENABLED - Enable UARTE0 instance
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif

    // <o> NRFX_UARTE1_ENABLED - Enable UARTE1 instance
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif

    //NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver

    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    // <o> NRFX_UART0_ENABLED - Enable UART0 instance
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 0
    #endif

    // <e> UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer
    //==========================================================
    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif


    // <e> UART0_ENABLED - Enable UART0 instance
    //==========================================================
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 1
    #endif
    // <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA

    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 1
    #endif

    // </e>

    // <e> UART1_ENABLED - Enable UART1 instance
    //==========================================================
    #ifndef UART1_ENABLED
    #define UART1_ENABLED 0
    #endif

  • Can there have a complete using uart0 and uart1 transmission example? It's difficult for me to work for it. And I also find I can not use two UARTs(UART1 and UART0) at the same time.By configurating APP_UART_DRIVER_INSTANCE 0/1, I can use UART0/UART1 respectively.

Related