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

Mapping LGA pins (TX and RX) to any castellated pins on the nrf52840 (Fanstel BT840F module) internally in software?

Relative newbie here. Would like to interface an Arduino MCU (AVR 328p/32u4, etc) via UART protocol with a decent range (50-100m open air) nrf 52840.  I found the Fanstel BT840F amplified nrf52840 module with a long range. 

The Fanstel datasheet (see link) shows an "Arduino - UART - nRF52840" hardware interface .  Seems straightforward (see below diagram).  Just sending some simple short strings via UART from the Arduino via serial and the nrf52840 sends them out.  

But from the required pins for the UART to work, the only castellated pins are 3V3, GND, P026 (Wake up), and P003 (COMD).  The TX  (p102) and RX (p101) pins are D5 and C5 LGA pins on the BT840F module.  Can I map pins 101 and 102 in software to couple of the castellated pins...for example module physical pin #15 (SWCLK) / pin #16 (SWDIO)? 

Any precautions, notes, that I should be aware of before embarking on this?  

Here is the relevant UART hardware interface guide to the Fanstel BT840F nrf52840 module (pages 6-10): 

https://static1.squarespace.com/static/561459a2e4b0b39f5cefa12e/t/5c0071e01ae6cf3870de2daa/1543533029528/Fanstel_AT_Commands.pdf

I did some more search.  So any pins with a dedicated function, like SWCLK and SWDIO, etc are OFF-LIMITS for mapping due to potential conflict.   Also, recommended to use hardware UART vs UARTe.  The nrf52840 has native USB so no need for any other chips to communicate with an Arduino's UART, Serial. 

Just to emphasise, I am limited to the Arduino IDE.   I have the Seger edu kit, but have not used it yet, nor do I have the NRF SDK..  I hope to stay with the relative safety of Arduino, unless no other options. 

I believe if I use an NRF52840 module then I can use the Adafruit nrf52 firmware and bootloader that already has UART support.  I could change the pin mapping in the Aurduino code maybe?  Or need access to the source code of the Adafruit firmware?  

Found a code snippet example for pin mapping:

#if defined (UARTE_PRESENT)
#include "nrf_uarte.h"
#endif

#define UART_TX_BUF_SIZE 256                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**< UART RX buffer size. */

#define UART_RX_PIN 29
#define UART_TX_PIN 31
#define UART_RTS_PIN UART_PIN_DISCONNECTED //Pin not used
#define UART_CTS_PIN UART_PIN_DISCONNECTED //Pin not used

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_communication);
    }
    else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_code);
    }
}

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code;

    const app_uart_comm_params_t comm_params =
      {
          UART_RX_PIN,
          UART_TX_PIN,
          UART_RTS_PIN,
          UART_CTS_PIN,
          APP_UART_FLOW_CONTROL_DISABLED,
          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);

    printf("\r\nUART example started.\r\n");

    while (true)
    {
        printf("TestString!\r\n");
        nrf_delay_ms(500);
    }
}

  • Just to emphasise, I am limited to the Arduino IDE.   I have the Seger edu kit, but have not used it yet, nor do I have the NRF SDK..  I hope to stay with the relative safety of Arduino, unless no other options. 

     If this is a requirement for you, you need to look into an Arduino forum. It is not something that we support. The code snippet that you found doesn't look very Arduino like. It looks like a snippet from our SDK. 

    To be honest, I am not sure about your HW setup. Do you have an Arduino chip which you want to communicate to the nRF52840 over UART, or is the arduino chip the nRF52840?

  • Thank you for the reply.  The chip I plan to use would be either the Atmel AVR 328p or the 32u4 MCUs.  The 32u4 already has native USB support.  The 32u4 (or 328p) would be hardwired to the NRF52840 via UART.   

    What I am hoping to replicate is the Adafruit Feather 32u4 Bluefruit LE module.  It has a 32u4 MCU and a NRF51822 on the same board connected via SPI.   I want to replace the NRF51822 with a NRF52840 and use UART.     I figured that that would be the easiest by modifying the Adafruit Arduino firmware written for the NRF52840.

    The NRF51822 does not have a strong enough BLE signal even at +4db, and I hope the NRF52840 at +8db would work.  The Fanstel NRF52840 "BT840F" is I think amplified to +18db.

    The code snippet is Nordic, but I hope to adopt it to Adafruit's Arduino firmware for the NRF52840 once I figure out the internal pin mapping of the NRF52840. 

  • As for the arduino part, I would check this in an Arduino forum. I think you have a better shot there. 

    As for the nRF52840, most of the pins are SW configurable. The SW... pins are some of the exceptions. Aim for the pins named PXYZ. I assume this refers to PX.YZ (P0.00 - P1.15). If the nRF52840 has an external LFXTAL, you should reserve pin P0.00 and P0.01 as well.

    BR,

    Edvin

  • Thank you.  Will dive in deeper in the guides about the pins.

Related