CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

DSPIC33EP512GP502 -- PCD v5.115 compiler - Bootloader issue
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marco27293



Joined: 09 May 2020
Posts: 136

View user's profile Send private message

PostPosted: Wed Feb 26, 2025 2:47 am     Reply with quote

Here the main steps related to fft computation.

Code:

#define FFT_LENGTH 512
#define SAMPLE_SIZE 2048
#include <Lib/fft.h>

typedef struct _complex
{
   fft_int_t re;
   fft_int_t im;
} Complex;
#endif

signed   int32 samples32[SAMPLE_SIZE];
Complex        samples[SAMPLE_SIZE];

fft_init();

for(i=0;i<=FFT_LENGTH*3; i+=FFT_LENGTH)
{
   fft((samples+i), FFT_LENGTH);
   filter_res=SPECTRUM_Filter();
   if(filter_res>0)             
      count++;
        if(count>=supp)
            break;
}

//NOTE:
1) SPECTRUM_Filter(); checks computed spectrum in x_data array

2) fft.h library memory management includes:

#banky
Complex twiddle[FFT_LENGTH / 2];

/* x_data: fft data array used for the in-place, radix-2, DIT FFT.  A pointer
 * to this memory array is returned by all FFT and IFFT functions.  This
 * array must be as long as the largest data sample to be transformed (nominally
 * 64 complex values).  This array must be located at 0x1000 for bit reversing
 * up to 2048 points, or at 0x0800 for bit reversing up to 1024 points.
 */
Complex x_data[2*FFT_LENGTH];
//#locate x_data = 0x0800  //old
#locate x_data = 0x1000 //fix for EP

/* FFT function:
 * Transforms a series of time-domain samples into the
 * frequency-domain. This algorithm uses a radix-2, DIT FFT.
 *
 * -This function requires operates on buffers that are exactly a power of 2.
 *  16384 is the maximum possible number of samples, however,
 *  this much memory may not be available.
 * -Input samples are expected in signed, Q.15-fractional form; natural order
 * -The maximum value any sample should reach is .5 (0x4000)
 *  or overflow may occur.
 * -Samples are output in natural order into frequency bins of size Fs / (2 * N)
 * -This function returns a pointer to the Fourier Transform of cplx_input.
 *
 * cplx_tw are required twiddle factors as generated by build_twiddle().
 * These factors need be generated only once, but must be located in Y RAM.
 */


samples are 2048 signed int16 (max abs value 0x4000), I process 512 samples at a time.
Ttelmah



Joined: 11 Mar 2010
Posts: 19730

View user's profile Send private message

PostPosted: Wed Feb 26, 2025 7:33 am     Reply with quote

I notice your sample array doesn't have a bank statement. They normally
require this to ensure it does not get split.
However think it is more likely that it is the ROM usage, where functions
are perhaps resulting in long jumps/calls with the bootloader present.
Marco27293



Joined: 09 May 2020
Posts: 136

View user's profile Send private message

PostPosted: Mon Mar 03, 2025 8:10 am     Reply with quote

Could you help me to properly associate samples array to a memory bank ?
The problem persists when I have bootloader+application and fft.h library just included without using any of its functions.

In the library I have:

Code:

/* x_data: fft data array used for the in-place, radix-2, DIT FFT.  A pointer
 * to this memory array is returned by all FFT and IFFT functions.  This
 * array must be as long as the largest data sample to be transformed (nominally
 * 64 complex values).  This array must be located at 0x1000 for bit reversing
 * up to 2048 points, or at 0x0800 for bit reversing up to 1024 points.
 */
Complex x_data[2*FFT_LENGTH];
//#locate x_data = 0x0800  //old
#locate x_data = 0x1000 //fix for EP

....

#banky
Complex twiddle[FFT_LENGTH / 2];


Thse are my global variables:

Code:

//-----------------------------Global Variables----------------------------------//
unsigned int8  THS_array[7]={0,0,0,0,0,0,0};
unsigned int8  shift=0;
unsigned int16 wk_cause;
unsigned int16 sample_num=0;
signed   int16 input_buffer[INPUT_SIZE] = {};
unsigned int32 Arm_bits=0;
signed   int32 acc_sum=0;
signed   int32 samples32[SAMPLE_SIZE];
Complex        samples[SAMPLE_SIZE];


How can I manually allocate them ? Could you provide me an example with admissable memory values ?

The isr code needs about 45us to be performed but also slowing down my Fsampling ( I see with oscilloscope on INT_EXT1 pin a proper trigger period of 100us) I have:

- Data at Fsampling if I have fft.h included and standalone application
- Data at Fsampling if I have fft.h excluded and bootloader+application
- Data at Fsampling/2 if I have fft.h included and bootloader+application
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group