View previous topic :: View next topic |
Author |
Message |
Marco27293
Joined: 09 May 2020 Posts: 126
|
|
Posted: Mon Jul 31, 2023 6:43 am |
|
|
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: 126
|
|
Posted: Tue Aug 01, 2023 1:41 am |
|
|
Any suggestion ?
Is it 0x5000 location suitable ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Aug 01, 2023 7:02 am |
|
|
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: 126
|
|
Posted: Tue Aug 01, 2023 7:07 am |
|
|
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: 19539
|
|
Posted: Tue Aug 01, 2023 8:05 am |
|
|
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: 126
|
|
Posted: Tue Aug 01, 2023 8:23 am |
|
|
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: 19539
|
|
Posted: Tue Aug 01, 2023 9:12 am |
|
|
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: 19539
|
|
Posted: Tue Aug 01, 2023 9:42 am |
|
|
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: 126
|
|
Posted: Tue Aug 01, 2023 9:48 am |
|
|
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: 19539
|
|
Posted: Tue Aug 01, 2023 9:53 am |
|
|
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: 126
|
|
Posted: Tue Aug 01, 2023 9:58 am |
|
|
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: 19539
|
|
Posted: Tue Aug 01, 2023 11:41 am |
|
|
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: 126
|
|
Posted: Wed Aug 02, 2023 1:15 am |
|
|
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: 19539
|
|
Posted: Wed Aug 02, 2023 1:28 am |
|
|
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: 126
|
|
Posted: Wed Aug 02, 2023 1:33 am |
|
|
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 ? |
|
|
|