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 support@ccsinfo.com

DSPIC33EP512GP502 and FFT issue extending FFT_LENGTH
Goto page Previous  1, 2, 3, 4, 5  Next
 
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: 115

View user's profile Send private message

PostPosted: Mon Jul 31, 2023 6:43 am     Reply with quote

OK!

I used the library you sent to me few days ago.
I put:



Code:

Complex samples[FFT_LENGTH];
#locate samples = 0x5000


BUT 2048 fft result in x_data still seems NOT consistent...

Can you help me please ?
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 1:41 am     Reply with quote

Any suggestion ?

Is it 0x5000 location suitable ?
temtronic



Joined: 01 Jul 2010
Posts: 9125
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 7:02 am     Reply with quote

re:
Quote:
BUT 2048 fft result in x_data still seems NOT consistent...
How do you know this ?
What are you comparing the answer the PIC gives to ??
Are the 512 or 1024 FFT results accurate ??
Is it the actual result or how it's formatted to be displayed ??
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 7:07 am     Reply with quote

Also 512 and 1024 are not accurate.

When I use the standard bugged library with 512 sample fft long, I'm able to correctly get a consistent spectrum.

If I use the optimized library, my device does not reset anymore but data are not consistent (they seems random RAM values without peaks related to frequency domain).

I use data from ADC sampling a 440Hz audio signal detected by my analog microphones on the board.
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 8:05 am     Reply with quote

OK.
Sorry to have been so slow coming back. Lots to do at work, so didn't
have time to look at it. You could have done the same as I did. Simply
ran simulated data and ran my version versus the original with 512
entries. There is one more fix needed in the actual FFT routine. Have
done this and will post it privately in a moment.
It now gives identical results on a 512 entry table with mine versus the
original. So hopefully the 2048 entry setting will work.
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 8:23 am     Reply with quote

The problem persists, still NOT consistent data (I tested 128 fft long the error persists).

I suspect we're missing the point regarding a RAM issue...
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 9:12 am     Reply with quote

So, you need to do some diagnosis. Run a known array, through the
standard code at 512 samples. Look at it's copied and bit reversed data
at 0x9000. Then compare to this. Then run a single loop in the FFT routine
itself and again look at the values. Work out which part of the routine
fails.
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 9:42 am     Reply with quote

Are you running with interrupts enabled?.
If so, you need to look at erratum 23. This will apply to several instructions
in the assembler.
The chip you have chosen, has a lot of errata, and some of them seem to
be only partially documented.
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 9:48 am     Reply with quote

Where can I find this errata ?

In the datasheet ?

Anyway I have:

enable_interrupts(GLOBAL);

but when I process FFT no specific single interrupt is enabled...
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 9:53 am     Reply with quote

In the errata sheet for the chip. There are 47 separate errata for this chip.

In the code you sent you have both a timer and an external interrupt
used.
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 9:58 am     Reply with quote

OK, I found errata sheet for my dspic33.
I read erratum 23.

If I disable all the interrupts before to perform fft could I fix the problem ?

Is any workaround available like suggested DISI assembly instruction ??

Maybe using #org I can avoid problems in 0x0-0x200 program memory, I tried but I got error: Invalid org range...

How can I proceed ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Aug 01, 2023 11:41 am     Reply with quote

The 0 to 100 range includes all the main registers like W0 to W15
and chip control registers. Hence you can't avoid touching them.
One would have to walk through all the assembler and identify every
instruction that uses a register in this range, and add a DISI for the
following instruction in front of every one.
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Wed Aug 02, 2023 1:15 am     Reply with quote

So I only have to check the part of my code in which I use assembly ?

And above every instruction which refers to w0-w15 I should put a DISI ?

How many cycles have I to select for DISI ?

DISI #10 is sufficient ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Wed Aug 02, 2023 1:28 am     Reply with quote

No. You need to include all the other registers here. MORCON, CBREV,
CORCON etc. etc..
You should look at the instruction size for each DISI #I or DISI #2
according to the sizes involved.
Seriously, why not just load a standard non DSP C FFT library. There are
a couple of quite competent free ones, and all you sacrifice is speed.
Given how slow you are running the chip, speed doesn't seem to be your
target, so save yourself a lot of work.
Marco27293



Joined: 09 May 2020
Posts: 115

View user's profile Send private message

PostPosted: Wed Aug 02, 2023 1:33 am     Reply with quote

Should I check ONLY assembly part of my code ?

The rest written in C (using PCD compiler) is already ok ?

Anyway, could you suggest me a good FFT C library ?

Where Can I find it ?
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, 3, 4, 5  Next
Page 4 of 5

 
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