Allocation of Dynamic Memory

srinivas27194
Posts: 3
Joined: Thu Jul 30, 2020 2:32 pm

Allocation of Dynamic Memory

Postby srinivas27194 » Thu Jul 30, 2020 3:47 pm

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.

boarchuz
Posts: 292
Joined: Tue Aug 21, 2018 5:28 am

Re: Allocation of Dynamic Memory

Postby boarchuz » Thu Jul 30, 2020 4:30 pm

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).

srinivas27194
Posts: 3
Joined: Thu Jul 30, 2020 2:32 pm

Re: Allocation of Dynamic Memory

Postby srinivas27194 » Tue Aug 04, 2020 7:58 am

I have attached the code for your reference.
Attachments
MMD_Lite_tested.txt
(3.9 KiB) Downloaded 36 times

srinivas27194
Posts: 3
Joined: Thu Jul 30, 2020 2:32 pm

Re: Allocation of Dynamic Memory

Postby srinivas27194 » Sat Aug 15, 2020 4:59 am

May I kindly know if anyone can help on this ?

ESP_Sprite
Posts: 4003
Joined: Thu Nov 26, 2015 4:08 am

Re: Allocation of Dynamic Memory

Postby ESP_Sprite » Sat Aug 15, 2020 12:02 pm

Pretty sure boarchuz already gave some good starting points; did these not work out for you?

Who is online

Users browsing this forum: No registered users and 42 guests