Error while performing the infinite loop

Hi, 

Could you please advise, am designing a device using the nrf52dk-52832 in nrf sdk connect 2.5.1 and toolchain 2.5.2 that reads the previously adquired samples data from and ADC placed in an Eeprom thru I2c then placed in a 25000 bytes 16 bit array and then the 8 byte from the eeprom group them in a 16 byte register then filtered out to be 0 or 1 and finally turn on or off a pin with a delay in order to recreate the original waveform adquired in the eeprom.

the problem is that if i make shorts the loops of all this it works ok but if make the complete loops to complete the task the program goes into fatal error mode and restarts again. 

the idea its that once it reaches the point of recreating the waveform enters an infinite loop and stays there but in my case keep on crashing the software in the ksleep instruction, then i changed it for a while loop and then crashes at the end of the first output of the signal finishing the loop and so on.

I attached here to code for your reference:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
/* STEP 3 - Include the header file of the I2C API */
#include <zephyr/drivers/i2c.h>
/* STEP 4.1 - Include the header file of printk() */
#include<zephyr/sys/printk.h>
#include <zephyr/drivers/i2c/target/eeprom.h>
//#include <zephyr/timing/timing.h>
//#include <zephyr/drivers/entropy.h>
/* STEP 9 - Increase the sleep time from 100ms to 10 minutes */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX