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.

EK-TM4C123GXL: CMSIS-DSPLib real fft ends in FaultISR

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: TM4C123GH6PM

Hello,

I think I have successfully compiled the DSPLibrary in CCS 6.2 to use with the Tiva C TM4C123GH6PM. I did the procedure exactly like described in the doc "Using the CMSIS DSP Library in Code Composer Studio for TM4C MCUs" - spma041g.pdf

Just in step 6 on page 9 I cant select the "Use unified assembly language (--ual)" checkbox. I never found this option in the properties. Could this be a problem?

Out of the ARM example folder I ran the complex floating point example without any error. If I use the integer real fft to save resources the code jumps into FaultISR while executing line "arm_rfft_q15(.....".

#include "arm_math.h"
#include "arm_const_structs.h"

#define TEST_LENGTH_SAMPLES 1024	
extern uint16_t ui16InputTestData[TEST_LENGTH_SAMPLES];
static uint16_t ui16TestOutput[TEST_LENGTH_SAMPLES];
/* ------------------------------------------------------------------
 * Global variables for FFT Bin Example
 * ------------------------------------------------------------------- */
uint32_t fftSize = 1024;
uint32_t ifftFlag = 0;		/* forward fft*/
uint32_t doBitReverse = 1; 	/* output NOT in bitreversal*/

/* Reference index at which max energy of bin ocuurs */
uint32_t refIndex = 213, testIndex = 0;

/* ----------------------------------------------------------------------
 * Max magnitude FFT Bin test
 * ------------------------------------------------------------------- */

int32_t main(void) {
	arm_rfft_instance_q15 fft_ins;

	// REAL integer FFT
	arm_rfft_init_q15(&fft_ins, fftSize, ifftFlag, doBitReverse);
	arm_rfft_q15(&fft_ins, (q15_t *) ui16InputTestData,
			(q15_t *) ui16TestOutput);

	while (1)
		; /* main function does not return */
}

/** \endlink */

What did I wrong?

Thanks for any suggestions.

  • If I use the integer real fft to save resources the code jumps into FaultISR while executing line "arm_rfft_q15(.....".

    Have you tried to debug into that function ?

    What do the SCB registers say about the hardfault cause ?

  • void arm_rfft_q15(
        const arm_rfft_instance_q15 * S,
        q15_t * pSrc,
        q15_t * pDst)
    {
        const arm_cfft_instance_q15 *S_CFFT = S->pCfft;
        uint32_t i;
        uint32_t L2 = S->fftLenReal >> 1;
    
        /* Calculation of RIFFT of input */
        if(S->ifftFlagR == 1u)
        {
            /*  Real IFFT core process */
            arm_split_rifft_q15(pSrc, L2, S->pTwiddleAReal,
                                S->pTwiddleBReal, pDst, S->twidCoefRModifier);
            
            /* Complex IFFT process */
            arm_cfft_q15(S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR);
            
            for(i=0;i<S->fftLenReal;i++)
            {
                pDst[i] = pDst[i] << 1;
            }
        }
        else
        {
            /* Calculation of RFFT of input */
            
            /* Complex FFT process */
            arm_cfft_q15(S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR);
    
            /*  Real FFT core process */
            arm_split_rfft_q15(pSrc, L2, S->pTwiddleAReal,
                                S->pTwiddleBReal, pDst, S->twidCoefRModifier);
        }
    }

    Above you can have a look at the fft function this fault occurs. Debugging into arm_split_rfft_q15() is not possible. Controller halts immediately. 

    I searched for the SCB register in the "Registers" tab but can't find any of them. In witch root category they are located?

  • Above you can have a look at the fft function this fault occurs. Debugging into arm_split_rfft_q15() is not possible. 

    If you have the sources (you use to have for the CMSIS-DSP lib), why can't you debug it ?

    Controller halts immediately.

    Now that is an assumption. Most interesting is where exactly it happens.

    You don't have/use a link library build for ARM code instead of Thumb2, do you ?

    I searched for the SCB register in the "Registers" tab but can't find any of them. In witch root category they are located?

    I don't have/use CCS. Look here for a description of what I mean:

    www.keil.com/appnotes/files/apnt209.pdf

  • Simon Wolf said:
    I searched for the SCB register in the "Registers" tab but can't find any of them. In witch root category they are located?

    See Diagnosing Software Faults in Stellaris® Microcontrollers for the registers in the CCS debugger to diagnose the cause of a hard fault.

    [The app note was written for Stellaris devices, but is still applicable to Tiva devices]

    Edit: Corrected the document link

  • f. m. said:
    You don't have/use a link library build for ARM code instead of Thumb2, do you ?

    I'm not sure if I understand your question. I didn't use a precompiled library. I'm not very deep into the different instruction sets and because of the missing compiler option I wrote above I have no idea which is used by CCS.

    I found another project what is using the DSPLib on a Stellaris LM4F120 LaunchPad. At line 772 there is a very interesting comment. So these guys also got in trouble with the integer fft.

    https://github.com/EuphonistiHack/launchpad-freq-analyzer/blob/master/StellarisWare/boards/ek-lm4f120xl/led_equalizer/led_equalizer.c

     

    //
    	// Ugly, ugly, ugly part where we have to move the ul samples into a float
    	// array because the fixed point fft functions in CMSIS seem to be not
    	// working.  While we're at it, we might as well center the samples around
    	// 0, as the CMSIS algorithm seems to like that.
    	//
    	for(i=0;i<NUM_SAMPLES;i++)
    	{
    		g_fFFTResult[i] = ((float)g_ulADCValues[i] - (float)0x800);
    	}
    
    	//
    	// Calculate FFT on samples
    	//
    	arm_rfft_f32(&fftStructure, g_fFFTResult, g_fFFTResult);
    

    At this point I have no idea how to proceed further.

    By the way, thanks a lot for supporting me!

  • I'm not sure if I understand your question. I didn't use a precompiled library.

    I suppose you should have the DSP lib sources than (as part of the project), and should be able to debug it.

    I'm not very deep into the different instruction sets and because of the missing compiler option I wrote above I have no idea which is used by CCS.

    At least a superficial knowledge is helpful here - I have to use a "cheat sheet" as well to decode more complex instructions.

    However,  Thumb2 is a sub-set of the ARM instruction set, and Cortex M supports only Thumb2. Libraries compiled for ARM usually fail at the very first function called. But modern tools warn you already at link time about that.

    I found another project what is using the DSPLib on a Stellaris LM4F120 LaunchPad. At line 772 there is a very interesting comment. So these guys also got in trouble with the integer fft.

    Not exactly - he called the floating point variant. Not sure how old this code is, and based on what CMSIS version. And I understand this comment as related to the transformation results - in a mathematical sense.

    I used this (the DSP lib routines, float variant) in several M4 projects, without such problems. I have a working (test) project for the LM4C to measure performance, so I know it's working there, too.

    At this point I have no idea how to proceed further.

    As a quick test, you can try to increase the stack size, as set in your project settings. Some IDEs tend to set ridiculously small values. I suggest at least 1 kByte.

    And, you can post the offending assembler instruction (including some of the preceeding one's) here, and the contents of the SCB->CFSR, SCB->HSFR, SCB->MMFAR and SCB->BFAR registers.

    And I suggest to print out that linked Keil app note and file it - this is not the last time you will need it ...