This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28335: TMS320F28335

Part Number: TMS320F28335


Tool/software: Code Composer Studio

Hi,

I worked on RFFT code. Can you explain me how below code reversed the bits......

I am confused with the code.

_rfft_adc_f32_Stages1and2and3andBitReverse:
;----------------------------------------------------------------------
; Save all save-on-entry registers used
;----------------------------------------------------------------------
PUSH XAR1
PUSH XAR2
PUSH XAR3
MOV32 *SP++,R4H
MOV32 *SP++,R5H
MOV32 *SP++,R6H
MOV32 *SP++,R7H
ADDB SP,#14h

MOVL XAR2,*+XAR4[0] ; &Inbuf
MOVL XAR5,*+XAR4[2] ; &Outbuf
SUBB XAR5, #2
MOVL XAR4, XAR5
MOVL XAR5,*+XAR4[2] ; &Outbuf
MOVL XAR3,*+XAR4[2]
ADDB XAR3,#8 ; &Outbuf[4]
MOVL XAR7,*+XAR4[4] ; &CosSinbuf

MOV AR0,#0Ah
MOV AH,*+XAR4[AR0] ; FFT SIZE
LSR AH,1 ; FFT SIZE/2 - for 16-bit input data
MOV AR0,AH
; LSR AH,3
LSR AH,2 ; for 16-bit input data
SUBB AH,#1 ; (Size / 8) - 1
MOVL XAR1,#0000h ; index if memory is not aligned

RPTB _rfft_32_Last, AH
;--------------------------------------------------------------------------------
; Input buffer must be aligned for this code
;--------------------------------------------------------------------------------
NOP *,ARP2
MOVI32 R4H, 0x39800801
UI16TOF32 R0H, *BR0++ ;I1 load
UI16TOF32 R1H, *BR0++ ;I2 load
MPYF32 R0H, R0H, R4H ;I1 scale
UI16TOF32 R2H, *BR0++ ;I3 load
MPYF32 R1H, R1H, R4H ;I2 scale
|| MOV32 *-SP[I1], R0H ;I1 save
UI16TOF32 R0H, *BR0++ ;I4 load
MPYF32 R2H, R2H, R4H ;I3 scale
|| MOV32 *-SP[I2], R1H ;I2 save
UI16TOF32 R1H, *BR0++ ;I5 load
MPYF32 R0H, R0H, R4H ;I4 scale
|| MOV32 *-SP[I3], R2H ;I3 save
UI16TOF32 R2H, *BR0++ ;I6 load
MPYF32 R1H, R1H, R4H ;I5 scale
|| MOV32 *-SP[I4], R0H ;I4 save
UI16TOF32 R0H, *BR0++ ;I7 load
MPYF32 R2H, R2H, R4H ;I6 scale
|| MOV32 *-SP[I5], R1H ;I5 save
UI16TOF32 R1H, *BR0++ ;I8 load
MPYF32 R0H, R0H, R4H ;I7 scale
|| MOV32 *-SP[I6], R2H ;I6 save
MPYF32 R1H, R1H, R4H ;I8 scale
MOV32 *-SP[I7], R0H ;I7 save
MOV32 *-SP[I8], R1H ;I8 save

Nikhil

  • Hi Nikhil,

    Where you see *BR0++, the code is using a bit reversed indirect addressing mode.  There is more information from p.93 in the C28x CPU & Instruction Set Guide, here:

    Regards,

    Richard

  • Thanks for your reply....i got my answer.

    can you please throw some more focus on..how scaling works...

    MOVI32 R4H, 0x39800801 ; scaling factor
    UI16TOF32 R0H, *BR0++ ;I1 load
    MPYF32 R0H, R0H, R4H ;I1 scale
  • Hi Richard,

    i got how scaling works...as it is floating point to hex calculation give 1/4095

    Can you help me with below query?
    I modified code to capture fft up to 1250 Hz for 50 Hz cycle. I kept sampling frequency as 4096 Hz Is it sufficient or I need to increase the frequency in order to collect 2^11 i.e. 2048 points.


    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File
    #include "math.h"
    #include "float.h"
    #include "FPU.h"
    #include "string.h"
    #include "DSP2833x_Examples.h"

    #pragma CODE_SECTION(adc_isr, "ramfuncs");


    extern void InitFlash(void);

    #define RFFT_STAGES 11
    #define RFFT_SIZE (1 << RFFT_STAGES)
    #define SCIMAX 6
    #define ADC_BUF_LEN RFFT_SIZE // ADC buffer length
    #define ADC_SAMPLE_PERIOD 18310 // 4096 Hz sampling w/ 75 MHz SYSCLKOUT

    #define F_PER_SAMPLE 4096.0L/(float)RFFT_SIZE //Internal sampling rate is 4096 Hz


    nikhil
  • Hi Nikhil.

    Can you clarify "...capture fft up to 1250 Hz for 50 Hz cycle" please?  Are you saying you sample over a 20ms interval and you want to resolve frequencies up to 1250 Hz? Thanks.

    Regards,

    Richard

  • Hi Richard,

    My input signal frequency is 50 Hz. My signal will have harmonics up to 25th order. i.e. 50 x 25 = 1250 Hz.
    I am generating adc interrupt using EPWM with frequency of 4096 Hz.

    I want to know, Is 4096 Hz frequency is sufficient to perform my job?
    How many samples will be collected for 50 Hz signals using 4096 Hz switching frequency and is it enough?

    Moreover, I want to change the code to detect time varying harmonics. Can you guide me how can I change the code.

    The code is here under link.....drive.google.com/.../1Yf3vnONBwRBQyvimELnMOQfOptgM6Bp5
    Also help me load the code in flash memory.....
  • Hi Richard,

    My input signal frequency is 50 Hz. My signal will have harmonics up to 25th order. i.e. 50 x 25 = 1250 Hz.
    I am generating adc interrupt using EPWM with frequency of 4096 Hz.

    I want to know, Is 4096 Hz frequency is sufficient to perform my job?
    How many samples will be collected for 50 Hz signals using 4096 Hz switching frequency and is it enough?

    Moreover, I want to change the code to detect time varying harmonics. Can you guide me how can I change the code.

    The code is here under link.....

    drive.google.com/open

    Also help me load the code in flash memory.....
  • Hi Nikhil,

    The RFFT will deliver real and complex arrays, each of which is N/2 points in length (N is your FFT size). These arrays capture equally spaced frequencies between 0 Hz and half the sample rate (2048 Hz in your case), so yes, in principle you should be able to work with your existing sample rate to capture 1250 Hz. I'm still not following your comment about 2^11 points though. The number of points in your FFT will affect the resolution of your frequency arrays, not the maximum frequency you can detect.

    Regret Google Drive is blocked by the TI firewall so I cannot see the code, however please keep in mind the forum is here to provide answers to specific questions.

    Can you open a separate post for the flash question please as it will likely be someone else who picks that up. If you haven't already seen it, you may find the application note useful:
    http://www.ti.com/lit/an/spra958l/spra958l.pdf

    Regards,

    Richard

  • Hi Richard,

    Please correct me if I am wrong... I am thinking to have 2 ^ 11 points to cover 1250 Hz signal. If it is not then how much setting for RFFT stages I need to make.....
  • Hi Nikhil,

    This will be fine.

    Regards,

    Richard
  • Hi Richard,

    Thanks for your quick reply....

    FFT for steady state harmonics is working fine..
    Now I want to try Sliding Window Recursive DFT....

    Is there any sample code available for SWR DFT?

    If yes then please guide me for that

    Nikhil
  • Hi Nikhil,

    Sorry, I don't think we have any sample code for that.

    Regards,

    Richard