I made a program that first calculates the FFT of a signal, in this case is a sinus, and then sends it through the serial port. Then the variable "N" is the number of points that I take sinus signal, as a function of N I have an array of signal values larger or smaller. The value of N has to be a power of 2 to run the algorithm. The program runs correctly until N = 1024, when I test with N => 2048 points and not just run, it seems that the program counter is lost. As the program progresses LEDs are lit to know at what point to running. I noticed that it stops executing when it enters the void FFT function. But not know why you lose at that point. Someone can help me or give an idea of what may be the problem? program My program code is as follows:
You should check your RAM usage, because in your code you define 4 float arrays with N elements (i count cosval and sinval in TWIDDLE struct as one array with N elements, as both have N/2 elements): datos[N], datos_real[N], datos_imag[N] and the said TWIDDLE struct. As a float value uses 4 bytes (32 bit), with 1024 points you already use 16 kB of RAM only for the arrays. With 2048 points you would need 32 kB only for the arrays.
It's of course true that the LPC1768 has 64 kB of RAM, but only the lower 32 kB are readily accessible for global and local variables and must share the space with stack and heap. So actually with 2048 points your code just crashes, because the arrays overlap with stack and heap.
You can use the upper 32 kB of RAM only if you don't use some specific peripherals (ethernet and ... i don't remember which ones exactly) as two blocks of 16 kB, but you have to use specific declaration directives (search for AHB RAM in this forum) for the definition of variables in that space.
Thanks for your response Neni.
I now look like being able to use that memory space with the definitions you told me. Another solution is also thought
use a dynamic array, because this is a part of the program, I have to put it together with more programs and do not think I get the memory. Nose be viable if using dynamic arrays and go keeping the sdcard results in a memory and communicate with it via i2c to go saving or loading data from 1024 in 1024.
Also thanks again for the answer.
Please log in to post a reply.
mbed, the fastest way to prototype with ARM based microcontrollers.
^ back to top