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 Reply Children
  • 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.

Related