Esp32-(xQueueGenericReceive)- assert failed

Hey guys i have been working on a project in which the analog values sampled at a particular frequency and stored in array. Then the value will be sent to user application ESP32 BLE. But I got stuck in this error.

/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceive)- assert failed! abort() was called at PC 0x4008e1d5 on core 1

Backtrace: 0x40091b38:0x3ffe0b20 0x40091d69:0x3ffe0b40 0x4008e1d5:0x3ffe0b60 0x400d1a2d:0x3ffe0ba0 0x4008e525:0x3ffe0be0

Rebooting... ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:8896 load:0x40080400,len:5816 entry 0x400806ac

I am Using Esp32arduino and Free Rtos for programming i error is in the semaphore from the interrupt but i couldn't able to find out exact solution. Please help me out guys

#include <ArduinoJson.h>
 #include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu = 0;
#else
static const BaseType_t app_cpu = 1;
#endif

//ADC Related Global Variables
static const uint16_t timer_divider =80;
static const uint64_t timer_max_count=1000;

static const int adc_pin=A0;

static const int BUF_SIZE=1000;

static int buf[BUF_SIZE];
int Buff_Len=0;
static int Read=0;
static int Write=0;
static int count=0;
static float avg=0;
int i=0;
int BLE_flag=0;
String cmd;

static hw_timer_t *timer=NULL;
static uint16_t val;
static int count1=0;

static SemaphoreHandle_t bin_sem=NULL;
static SemaphoreHandle_t bin_sem2=NULL;
static portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
//ADC Related Global Variables

//BLE Global Variable
char Reading[4];
BLEServer *pServer = NULL;
BLECharacteristic * pTxCharacteristic;
bool deviceConnected = false;
bool oldDeviceConnected = false;

//Declaration BLE necessary Classes
#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" // UART service UUID
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"

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

void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
}; //BLE Global Variables

//Task Section
void IRAM_ATTR onTimer()
{
//sampling

xSemaphoreGiveFromISR(bin_sem2,&task_woken);

if (task_woken) {
portYIELD_FROM_ISR();
}
}

void move_to_Queue (void *parameters)
{
while(1)
{
xSemaphoreTake(bin_sem2,portMAX_DELAY);

if(Buff_Len==BUF_SIZE||count1>2000)
{
Serial.println("Buffer is full");
xSemaphoreGive(bin_sem);

}
else
{
// storing the instantaneous sample value to buffer
}
}
}

void BLE_Task(void *parameters)
{ while(1) {

xSemaphoreTake(bin_sem,portMAX_DELAY);
Serial.println("BLE");
// sending the data\lu
delay(10); // bluetooth stack will go into congestion, if too many packets are sent
}
}
Serial.println();

}
}

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
vTaskDelay(1000/portTICK_PERIOD_MS);

 //BLE Declarations
 BLEDevice::init("UART Service"       );
 pServer = BLEDevice::createServer();
 pServer-&gt;setCallbacks(new MyServerCallbacks());
 BLEService *pService = pServer-&gt;createService(SERVICE_UUID);
 pTxCharacteristic = pService-&gt;createCharacteristic(
            CHARACTERISTIC_UUID_TX,
            BLECharacteristic::PROPERTY_NOTIFY
          );

 pTxCharacteristic-&gt;addDescriptor(new BLE2902());
 pService-&gt;start();
 pServer-&gt;getAdvertising()-&gt;start();
 Serial.println("Waiting a client connection to notify...");
 //BLE Declaration


 //ADC Semaphore and Timer Declarations
 bin_sem = xSemaphoreCreateBinary();
 bin_sem2 = xSemaphoreCreateBinary();


 if(bin_sem==NULL||bin_sem2==NULL)
 {
   Serial.println("Could not create semaphore");
   ESP.restart();
 }
   xTaskCreatePinnedToCore(move_to_Queue,
                  "move_to_Queue",
                  1024,
                  NULL,
                  2,
                  NULL,
                  app_cpu);
    xTaskCreatePinnedToCore(BLE_Task,
                  "BLE_Task",
                  2048,
                  NULL,
                  2,
                  NULL,
                  app_cpu);
          
    timer = timerBegin(0, timer_divider, true);

 // Provide ISR to timer (timer, function, edge)
    timerAttachInterrupt(timer, &amp;onTimer, true);

 // At what count should ISR trigger (timer, count, autoreload)
    timerAlarmWrite(timer, timer_max_count, true);

 // Allow ISR to trigger
    timerAlarmEnable(timer);
     vTaskDelete(NULL);

}

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

}

Thanks in advance guys

@khottabhutta Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

Your post was MOVED to its current location as it is more suitable.

edit the OP and put the code in code tags.

Decode the exception error using the ESP Exception Decoder.

Decoding stack results
0x4008e1d5: rtc_init at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/soc/esp32/rtc_init.c line 58
0x400d1a2d: std::__shared_ptr ::reset (WiFiClientSocketHandle*) at c:\users\kesourla\documents\arduinodata\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\bits/shared_ptr_base.h line 579
0x4008e525: rtc_clk_cal_internal at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/soc/esp32/rtc_time.c line 68