Page 1 of 1

Allocation of Dynamic Memory

Posted: Thu Jul 30, 2020 3:47 pm
by srinivas27194
We are trying to capture six signals each with 4096 samples and sampling at 500 Hz.
vImag = 0.0;
vReal = (3.3/4095.0)*analogRead(25);
vReal1=(3.3/4095.0)*analogRead(26);
vReal2=(3.3/4095.0)*analogRead(27);
vImag1 = 0.0;
vImag = 0.0;
There was an error "dram segment data does not fit"

So we modified the code by referring to various suggestions provided online by adding pointers and using calloc function.

vReal = (float*)calloc(1,4096);
vImag = (float*)calloc(1,4096);

This time there was no error but when we displayed the result in serial monitor, there was a stack overflow message and there was no output displayed. Please let us know what could be the possible reason and how we could overcome this issue.

Re: Allocation of Dynamic Memory

Posted: Thu Jul 30, 2020 4:30 pm
by boarchuz
Are you sure it's a stack overflow? You can try increasing the task stack size, or share the code here if you think it shouldn't be happening.

Check those allocs. If you want enough memory for 4096 floats, you'll need 4096 * sizeof(float).

Re: Allocation of Dynamic Memory

Posted: Tue Aug 04, 2020 7:58 am
by srinivas27194
I have attached the code for your reference.

Re: Allocation of Dynamic Memory

Posted: Sat Aug 15, 2020 4:59 am
by srinivas27194
May I kindly know if anyone can help on this ?

Re: Allocation of Dynamic Memory

Posted: Sat Aug 15, 2020 12:02 pm
by ESP_Sprite
Pretty sure boarchuz already gave some good starting points; did these not work out for you?