ESP32 TG1WDT_SYS_RESET when continuous reading ADC and BLE server

Hello everyone. When I try to pair with the BLE, the watchdog resets the microcontroller. I tried to extend the watchdog times, but the problem seems to be the sharing of the DMA. Does anyone have a suggestion?
The uP used is a ESP32 Wroom.
The code to reproduce the problem:

#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
/*Variabili per libreria BLE*/
BLEServer *pServer = NULL;
BLECharacteristic *pTxCharacteristic;
bool deviceConnected = false;
bool oldDeviceConnected = false;
#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"  // UART service UUID
#define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"


uint8_t adc_pins[] = { 36, 39, 34};
uint8_t adc_pins_count = sizeof(adc_pins) / sizeof(uint8_t);
void start_analogiche(void) {

  analogContinuousSetWidth(12);
  analogContinuousSetAtten(ADC_11db);
  if (analogContinuous(adc_pins, adc_pins_count, 100, 20000, NULL)) {
    Serial.println("analogiche configurate!");
  }
  if (analogContinuousStart()) {
    Serial.println("analogiche on!");
  }
}

class MyServerCallbacks : public BLEServerCallbacks {
  void onConnect(BLEServer *pServer) {
    deviceConnected = true;
  };

  void onDisconnect(BLEServer *pServer) {
    deviceConnected = false;
  }
};

class MyCallbacks : public BLECharacteristicCallbacks {
  void onWrite(BLECharacteristic *pCharacteristic) {
    String rxValue = pCharacteristic->getValue();
    int len = rxValue.length();
    if (len > 0) {
      Serial.printf("********* Pacchetto ricevuto di %d bytes:\n\r", len);
    }
  }
};

void init_uart_ble(void) {

  // Create the BLE Device
  BLEDevice::init("ESP32");

  // Create the BLE Server
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());

  // Create the BLE Service
  BLEService *pService = pServer->createService(SERVICE_UUID);

  // Create a BLE Characteristic
  pTxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_NOTIFY);

  pTxCharacteristic->addDescriptor(new BLE2902());

  BLECharacteristic *pRxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX, BLECharacteristic::PROPERTY_WRITE);

  pRxCharacteristic->setCallbacks(new MyCallbacks());

  // Start the service
  pService->start();

  // Start advertising
  pServer->getAdvertising()->start();
  Serial.println("Attendo connessione...");
}



void setup() {
  Serial.begin(115200);
  start_analogiche();
  init_uart_ble();  
}

void loop() {
  // put your main code here, to run repeatedly:
}

first thing I noted was you have a Serial.printf() in the callback routine which can cause problems

try setting a volatile variable and printing the message in loop()

Thank you, Horace, I tried your suggestions but nothing changes. Decoding the backtrace, it seems that the problem is the sharing of DMA between continuous ADC and the BLE library.
I hope espressif resolves it.

try posting on the ESP32 Arduino forum?

I assume the BLE and ADC DMA work OK in separate programs?
do you need the ADC DMA?
how often do you require ADC readings?
could you use Timer interrupts to make regular ADC readings into double buffers for transmission over BLE

more details of the project requirements would help

Hello Horace, thank you for your time. The problem occurs only and exclusively when pairing is done. The piece of code reproduces the problem. If used alone or after pairing, both BLE and DMA work perfectly. The problem can easily be circumvented with some flags, but I was wondering if it could really be solved.