I'm trying to create an application on the nRF52840 that can read serial input from an external GPS chip and also provide log output via USB. As I understand it, the UART to USB output will occupy UART peripheral 0. So, I've configured the external GPS chip to connect via the UART peripheral 1 using UARTE. I've connected the TX pin from the GPS chip to P1.04 on the nRF52840 board. Here is my uarte_init() code:
#define SER_APP_RX_PIN NRF_GPIO_PIN_MAP(1,4)
#define SER_APP_TX_PIN NRF_GPIO_PIN_MAP(1,3)
static void uarte_init(void)
{
ret_code_t err_code;
nrfx_uarte_config_t config1 = {
.pseltxd = SER_APP_TX_PIN,
.pselrxd = SER_APP_RX_PIN,
.pselcts = 0xFFFFFFFF,// no cts pin
.pselrts = 0xFFFFFFFF,// no rts pin
.p_context = NULL,
.hwfc = 0,//disabled
.parity = NRFX_UARTE_DEFAULT_CONFIG_PARITY,
.baudrate = NRF_UARTE_BAUDRATE_9600,
.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
};
err_code = nrfx_uarte_init(&uarte1, &config1, NULL);
APP_ERROR_CHECK(err_code);
}
Then I try to read from the GPS with the following:
static char buf[64];
uint8_t c;
ret_code_t ret;
ret = nrfx_uarte_rx(&uarte1, &c, sizeof(c));
The ret is always code 3, which is NRF_ERROR_INTERNAL.
Any suggestions regarding what I'm doing wrong would be greatly appreciated. If I should accomplish this is a different way, I'd appreciate any suggestions along those lines as well.
