-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi, I have a project where I use Serial1 for exchanging data from a sensor. This data is then send via BLE to a Central. At startup, Serial1 is being initialized, and while running Serial1 data is vey frequently read out. Also the nRF52840 is connecting via BLE to the central (using LongRange). It all works, but after little time Serial1 dies. A workaround is that I now detect no incoming data for more than 4 seconds, and then perform a Serial1.end(); and then Serial1.begin(115200, SERIAL_8N1); It immediately starts again after that. But, after a while (20 secs to few minutes) Serial1 dies again and I need to .end and .start again.
Anyone has any experience with this?
I work on a custom nRF52840, configured much like a Adafruit Feather Sense (eg. with external crystal). I do not fully understand the way the Uarts are used, but with below platform.ini and variant.h I do have USB Serial ánd Serial1 for comms with my sensor:
platform = N-able
board = nRF52840_WHX
framework = arduino
monitor_speed = 115200
upload_protocol = jlink
debug_tool = jlink
lib_deps =
h2zero/NimBLE-Arduino@^2.3.0
milesburton/DallasTemperature@^3.11.0
upload_port = COM9
extra_scripts =
pre:build_versioning.py
board_bootloader = adafruit
build_flags =
-DARDUINO_GENERIC
-DUSE_LFRC
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
-DCONFIG_BT_NIMBLE_EXT_ADV=1
-DNRF52_SERIES
-DNRF52840_XXAA
;-DCONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT
;-DCONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT
;-DCONFIG_NIMBLE_CPP_ENABLE_ADVERTISEMENT_TYPE_TEXT
;-DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED
;-D CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED
;-D CONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED
;-D CONFIG_BT_NIMBLE_ROLE_OBSERVER=0
-DCONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN=31
The Variant.h file
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _VARIANT_FEATHER52840_SENSE_
#define _VARIANT_FEATHER52840_SENSE_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
//DJ specific
#define P0_00 (0) //0.00 *XL1
#define P0_01 (1) //0.01 *XL2
#define P0_02 (2) //0.02 *AI0, LF
#define P0_03 (3) //0.03 *AI1, LF
#define P0_04 (4) //0.04 AI2
#define P0_05 (5) //0.05 *AI3
#define P0_06 (6) //0.06 N
#define P0_07 (7) //0.07 N
#define P0_08 (8) //0.08 N
#define P0_09 (9) //0.09 *NFC1
#define P0_10 (10) //0.10 *NFC2
#define P0_12 (11) //0.12 N
#define P0_13 (12) //0.13 *N
#define P0_15 (13) //0.15 N
#define P0_17 (14) //0.17 N
#define P0_20 (15) //0.20 N
#define P0_22 (16) //0.22 QSPI
#define P0_24 (17) //0.24 *-
#define P0_26 (18) //0.26 N
#define P0_28 (19) //0.28 *AI4
#define P0_29 (20) //0.29 *AI5, LF
#define P0_30 (21) //0.30 *AI6, LF
#define P0_31 (22) //0.31 *AI7, LF
#define P1_00 (23) //1.00 N
#define P1_02 (24) //1.02 N
#define P1_04 (25) //1.04 LF
#define P1_06 (26) //1.06 LF
#define P1_09 (27) //1.09 *N
#define P1_10 (28) //1.10 *LF
#define P1_11 (29) //1.11 *N
#define P1_13 (30) //1.13 *LF
// Number of pins defined in PinDescription array
#define PINS_COUNT (31) //37
#define NUM_DIGITAL_PINS (31) //37
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
// #define PIN_LED1 (13)
// #define PIN_LED2 (4)
// #define PIN_NEOPIXEL (8)
// #define NEOPIXEL_NUM 1
// #define LED_BUILTIN PIN_LED1
// #define LED_CONN PIN_LED2
// #define LED_RED PIN_LED1
// #define LED_BLUE PIN_LED2
// #define LED_STATE_ON 1 // State when LED is litted
/*
* Buttons
*/
// #define PIN_BUTTON1 (7)
// // Microphone
// #define PIN_PDM_DIN 34
// #define PIN_PDM_CLK 35
// #define PIN_PDM_PWR -1 // not used
/*
* Analog pins
*/
#define PIN_A0 (14)
#define PIN_A1 (15)
#define PIN_A2 (16)
#define PIN_A3 (17)
#define PIN_A4 (18)
#define PIN_A5 (19)
#define PIN_A6 (20)
#define PIN_A7 (21)
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
#define ADC_RESOLUTION 14
// Other pins
#define PIN_AREF PIN_A7
#define PIN_VBAT PIN_A6
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (P0_03) //(1)
#define PIN_SERIAL1_TX (P1_10) //(0)
#define USB_CDC_DEFAULT_SERIAL 1
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (24)
#define PIN_SPI_MOSI (25)
#define PIN_SPI_SCK (26)
static const uint8_t SS = (5);
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (22)
#define PIN_WIRE_SCL (23)
// QSPI Pins
#define PIN_QSPI_SCK 27
#define PIN_QSPI_CS 28
#define PIN_QSPI_IO0 29
#define PIN_QSPI_IO1 30
#define PIN_QSPI_IO2 31
#define PIN_QSPI_IO3 32
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define EXTERNAL_FLASH_USE_QSPI
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif