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):
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);
}
}