HardFault_Handler Error for arm_rfft_fast_f32 and Execution timing for the same is required

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HardFault_Handler Error for arm_rfft_fast_f32 and Execution timing for the same is required

5,405 Views
gauravmore
Contributor III

Hi,

I am new to DSP functionality with respect to LPC CMSIS library. I hae implemented the small code in order to do real FFt on the hard coded samples. I refered the sample codes avaiable with LPC expresso library reagrding the CFFT function.

I have used following  initialization sequence.

#include "arm/arm_math.h"
#include "math_helper.h"

float32_t RealFFT_Input[128] = {

102, 97, 88, 74, 59, 43, 27, 9, -11, -35, -54, -69, -83, -92, -98, -101, -100, -95, -86, -73, -58, -41, -22, -5, 14, 31, 55,
72, 85, 95, 100, 103, 102, 96, 87, 75, 60, 42, 28, 9, -11, -35, -54, -69,
-83, -92, -98, -101, -99, -95, -86, -73, -58, -40, -22, -5, 13, 31, 56, 72, 85, 94, 101,
104, 102, 97, 88, 75, 60, 43, 28, 8, -11, -35, -54, -69, -82, -92, -98, -101, -100, -95,
-85, -73, -58, -41, -22, -5, 14, 32, 55, 72, 85, 95, 101, 103, 102, 96, 87, 75, 60, 43, 27,
8, -12, -35, -54, -70, -82, -92, -98, -101, -100, -94, -86, -73, -58, -41, -22, -4, 14, 31, 56, 73, 85, 94,
101, 104
};

float32_t RealFFT_Output[512];

float32_t RMSValue;

main(void)

{

arm_rfft_fast_instance_f32 rfft_Fast_instance;

arm_status status;

fftlen  = 32

arm_rfft_fast_instance_f32 *rfft_Fast_instance_Ptr = &rfft_Fast_instance;

status = arm_rfft_fast_init_f32(rfft_Fast_instance_Ptr, fftlen );

if(status == ARM_MATH_SUCCESS)
{
   arm_rms_f32(RealFFT_Input, Length, &RMSValue);


   arm_rfft_fast_f32(&rfft_Fast_instance, RealFFT_Input, RealFFT_Output, 0);
}

}

My code is getting compiled properly but when i put it ina debug mode i and getting the RMS value which is 71.213 some thing for 32 point RFFT.

but when i debug this function arm_rfft_fast_f32(&rfft_Fast_instance, RealFFT_Input, RealFFT_Output, 0);

my program counter goes to 

void HardFault_Handler(void)
{

while(1) { }
}

please let me know the resaon for the same. also find my code attached for reference.

I am using LPCexpreso V8.2.2.650 and the latest DSP library of CMSIS. I am running this code in LPC11u68 controller,

Also one more thing I want to know is the execution time of the DSP library used in CMSIS since it running in C code.

Is there anyone who has checked for the timming with respect the the aboe mentioned code  for RMS and RFFT.

Please provide the solution since my application is very time critical and expected time is in uS. 

Labels (3)
0 Kudos
25 Replies

3,595 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav,

  Do you check my modified code? Any updated information?


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,595 Views
gauravmore
Contributor III

Hi Kerry,

I have checked your code with my sample and the output is comming Proper.the execution time is aslo acceptable. It is around 20uS for FFT computation of 32 samples. I will furhter test the code with some more samples and verify it.

Thank you very much for providing me the ported solution. Thanks a lot. I will let you know if there is any problem regarding the same. 

Another query is that I want to know whether the same project support or works in LPCexpresso latest version whicherver it is. Or which version of LPC expresso I should be using considering any modification in the latest IDE Or  Whether I should use MCU expresso. and i if MCU expresso then whether there will be any issue in the execution of the code.

Please let me know mean while i will be using LPC expresso V8.2.2.2_650.

Thanks 

Gaurav More

0 Kudos

3,595 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav More,

    You are welcome, thank you for your updated information.

     Yes, you can use it with the latest LPCxpresso IDE, I also use V8.2.2.2_650 to test it.

     Besides, the MCUXpresso IDE can totally compatible with the LPCXpresso IDE, so you also can use our latest MCUXpresso.

Wish it helps you!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,600 Views
lpcxpresso_supp
NXP Employee
NXP Employee

First of all you should note that the CMSIS-DSP library projects supplied with LPCXpresso IDE have not been updated for some considerable time and are based on quite old versions of the CMSIS-DSP sources. If you are serious about using CMSIS-DSP, then you probably want to download the current version of the CMSIS sources from arm :

Anyway, that aside, it looks like your initial issue is being triggered by an issue previously reported on this forum (which I imagine is fixed in ARM's latest sources): 

To fix this, open up the CMSIS_DSPLIB_SRC project and navigate into

src -> dspcode -> TransformFunctions -> arm_bitreversal2.S

and change the following line:

#define CODESECT .section text

to:

#define CODESECT .section .text

However, there is a further problem in this file in that it is trying to force the target CPU to be Cortex-M4 when building for GCC. To fix this, delete or comment out the following 2 lines:

.cpu cortex-m4

.fpu softvfp

We also need to set a define in the assembler. This could be done on the command line, but the easiest way is to just add the following directly before the line "#if defined(ARM_MATH_CM0) || defined(ARM_MATH_CM0PLUS)":

#define ARM_MATH_CM0

Now build the CMSIS_DSPLIB_CM0 build configuration of the CMSIS_DSPLIB_SRC project (this will take a while!).

You now also need to make a change to your code in the DSP_FFT_Prj project. Open the file DSP_FFT_Prj.c, and move the following local variables out of main, so that they become globals.

arm_cfft_radix4_instance_f32 cfft_instance;

arm_rfft_instance_f32 rfft_instance;

arm_rfft_fast_instance_f32 rfft_Fast_instance;

Then save DSP_FFT_Prj.c, build the project and then debug, and this time you shouldn't see the hard fault.

Regards,

MCUXpresso IDE Support

0 Kudos

3,600 Views
gauravmore
Contributor III

Dear Sir,

With respect to the trailing mail, I have modified following sections as per suggestion.

and change the following line:

#define CODESECT .section text

to:

#define CODESECT .section .text

#define ARM_MATH_CM0PLUS

Commented below two lines

.cpu cortex-m4

.fpu softvfp

Moved below mentioned local variables above main.

arm_cfft_radix4_instance_f32 cfft_instance;

arm_rfft_instance_f32 rfft_instance;

arm_rfft_fast_instance_f32 rfft_Fast_instance;

Did the compilation as suggested below , but still the code is going to hard fault handler.

Also it is showing Error after compiling CMSIS_DSPLIB_SRC project

Please find the attached code for your reference.

Controller used is LPC11u68

Eval board used : OM1 3058

Kindly check the same revert ASAP.

Thanks & Regards

Gaurav More

EDDG, L&T - E&A IC

Direct: +91-22-6705 4029

0 Kudos

3,600 Views
lpcxpresso_supp
NXP Employee
NXP Employee

With respect to your earlier post : https://community.nxp.com/thread/475332#comment-1015904 ...

It looks to me like you didn't follow the instruction to rebuild the CMSIS_DSPLIB_CM0 build configuration of the CMSIS_DSPLIB_SRC project after making the required changes to it. If you build the CMSIS_DSPLIB_CM0 build configuration of the CMSIS_DSPLIB_SRC project, then do a clean and build of your DSP_FFT_Prj project, then you shouldn't see a  hard fault when the code runs (certainly I don't here).

Details of how to change the build configuration of a project in LPCXpresso IDE can be found in the FAQ :

Or if you switch to the current MCUXpresso IDE v10.2 release, this info can be found in section 18.3, "How do I switch between Debug and Release builds" of the MCUXpresso IDE v10.2 User Guide.

[ Although these talk about changing between Debug and Release build configurations, the same information applies to other build configurations when these exist in a project, as they do with the CMSIS_DSPLIB_SRC project.]

Regards,

MCUXpresso IDE Support

0 Kudos

3,595 Views
gauravmore
Contributor III

Hi,

I have already done  all the changes suggested but still there is a proble which  i have already posted to kerry,

I am having proble with the output of the FFT function in LPC expresso lDSP library.

Same when i use the keil DSP library it is generating proper output. Request you to please chec since i have already sent the code for both LPC expresso and Keils project . 

Kinldy provide the the response ASAP it he on very higher priority since not able to finalixze the controller due to such issues.

Thanks .

Gaurav More.

0 Kudos

3,595 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav,

    Please use my modified project:

https://community.nxp.com/servlet/JiveServlet/download/1030511-1-428904/Kerry%20modify.rar 

    This project already changed the source code with the newest DSP lib source code.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,595 Views
gauravmore
Contributor III

Hi Kerry,

Thanks for sharing the code. I will verify it  and let you know regarding the same in case there is any issue during the execution.

Thanks 

Gaurav More

0 Kudos

3,600 Views
gauravmore
Contributor III

Hi Kerry,

AS per you inpur i have used the DSP library available with keil. i am using keil uV5 for testing the DSP  on LPC11u68JBD100 controller. I am using the GPIO togglin method to chec the xecution time of the DSP CMSIS library.  I have attached to code for your reference. I am appying FFT for 32 points by using  arm_rfft_fast_init_f32 and arm_rfft_fast_f32 fundtion since it is supporting fft length 32 as well. i have checked the output of the function and it is comming proper . But the time taken for the arm_rfft_fast_f32  function comes around 760uS

This I have checked the above mentioned controller with M0+ core with 48MHz clock freq. I also checked the option of fast GPIO but it is not supported in LPC11u68JBD100 controller. This I have  confirmed with the controller user manual  UM10732 and IO address file LPC11U6x.h generated by keil editor after selecting the controller while creating the project.

I have attached the my prohect for your reference. I am using Keil uV5.16a . please check the code anf referify the same and revert ASAP since the speed and performance of the controller is not upto the mark with respect to my requierment since the timing to calculate FFT for length is 760uS, which is not acceptable.

Waiting for youre reply since it is very urgent,

0 Kudos

3,600 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav More,

    Thank you for your updated information.

    Your now project which use the keil DSP lib don't have the hard fault problem now.

    But about the wrong execute time, it is determined by the lib and the core clock, LPC11U68 max frequency is 50Mhz, if you use the max core clock, this lib execution time also can't meet your demand, I think maybe you need to choose the chip with higher core clock or the M4 core which can support the hardware float instruction.

  

Wish it helps you!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,599 Views
gauravmore
Contributor III

Hi kerry,

I have also checked with LPC4367 controller with M4 Code in LPC Expresso considering  your previous input regarding the change in the bitreversal.s file in the DSP source code. Now it does not go  in hardfalt handler. 

I checked the same code with M4 Controller in 100Mhz speed i got the result . but it is not proper. expected results are 

as follows,

SamplesOutput
102

233

1

97

1574.71588927697+

403.717759837946i

88

-60.757285752327 -

32.8848134800045i

74-11.2946889898969+ 22.4692145659635i
59

-7.2426406871193

-13.0710678118655i

43

17.9412551129291

-18.3472965264242i

27

1.28938314305984

-10.9350442385122i

9

-7.30748285305178

+5.63738343523862i

-11

-3

-4i

-35

4.64210702723309

-4.35798540098943i

-54

0.994888104401988

-3.13605436528891i

-69

-2.20949821140744

+5.99548402241127i

-83

1.24264068711928

-1.07106781186548i

-92

-2.73980859106423

-5.80532061540417i

-98

6.47301450486508

-1.08582360678129i

-101

2.25222722829517

+5.10507527151785i

-951
-86

2.25222722829494

-5.10507527151665i

-73

6.47301450486512

+1.08582360678121i

-58

-2.73980859106432

+5.80532061540458i

-41

1.24264068711929

+1.07106781186547i

-22

-2.20949821140769

-5.99548402241079i

-5

0.99488810440203

+3.13605436528886i

14

4.64210702723248

+4.3579854009903i

31

-3

+4i

55

-7.30748285305284

-5.63738343523798i

72

1.28938314305993

+10.9350442385122i

85

17.9412551129282

+18.3472965264248i

95

-7.24264068711927

+13.0710678118655i

100

-11.2946889898983

-22.469214565963i

103

-60.7572857523269

+32.8848134800047i

102

1574.71588927696

-403.717759837951i

Only first vlues 233 and 1 is proper rest all are wrong. Which is correct when i checked with keils DSP library for LPC4367 M4 Core. 

I have attached code for your reference. I think there might me some changes required in the DSP library imported with 
LPC Expresso.

Please check the same then i think my problem is solved since with thw wrong output the timing is aroung 20uS.

Request you to please check the code in expresso.

Thanks 

Gaurav More

0 Kudos

3,599 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav More,

   Could you also send me your LPC4367 KEIL DSP project, which can get the correct result?


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,599 Views
gauravmore
Contributor III

Hi Kerry,

Please find attached code for your reference. Kindly verify since was able to just check the output but not able to debug consistently. You can use this code to created  in your application tha verify.

Waiting for reply.

Thanks 

Gaurav More

0 Kudos

3,599 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav More,

    So sorry for my later reply!

   Now, I test your according code, and do a testing summarize:

    I have tested your MDK LPC4367 DSP code on my LPCXpresso LPC43S67 board, I can debug it with CMSIS DAP, the result is:

pastedImage_1.png

You can find I can debug it with the CMSIS DAP debugger. I didn't meet any debug problem, so I think you can use our official lpc43s67 lpcxpresso board to test it.

This is the LPC11U68 KEIL DSP project result:

pastedImage_2.png

I find these two chip result with KEIL DSP lib is the same, does these data are the correct data which you want?

This is the LPC43S67 DSP code with your LPCXpresso project result:

pastedImage_3.png

   Just as you said, yes, this project result is really not the same as the lpc11u68 and lpc4367 mdk dsp lib project.

So, please confirm again, the newest updated question is:

1. LPCXpresso DSP lib have problems in both lpc11u68 and lpc4367

   LPC11U68 enter hardfault, lpc4367 can't get the correct Rfft result.

2. MDK DSP lib can get the correct result with both lpc11u68 and lpc4367

  But you are very care about the execution speed, the LPC11U68 is very slow, but the LPC4367 MDK dsp project can meet your demand.

  Now, actually, the LPC4367 MDK DSP function already works on your side, but you need the MDK(keil) project about the multcore for the LPC43S67, is it correct?

If yes, please refer to our lpcopen code for lpc43xx mdk project, which can be downloaded from this link, I think you can add the MDK DSP lib to the official project.

https://www.nxp.com/downloads/en/libraries/lpcopen_3_02_keil_iar_xpresso4337.zip 

You can refer to the official code, there already have the multicore project, and the according project already support the complie and debug project.

 You can find the mdk project in folder:  lpcopen_3_02_keil_iar_xpresso4337\LPC43xx_18xx\prj_xpresso4337\keil, you can find some multi-project, that project already contains the peripheral lib, board lib and app project, you can select one project, and add your DSP lib to it.

Please try it on your side.

LPCX presso support is my colleague who I have mentioned and contact before, he is our LPCXpresso and MCUXPress IDE expert, if you still want to use the DSP lib in the LPCXpresso and MCUXpress IDE install path, he will help you about it.

If you want to use the MDK, I highly recommend you port the MDK DSP lib to our official lpcopen mdk project.

Any updated information on your side, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,599 Views
gauravmore
Contributor III

Hi Kerry,

Thanks a lot for your reply. Considering your input and the link shared I will download the project for keil and verify the same from my side.

The problem regarding the debug of code or project in keil with DAP is that every time i have to wake upt the debug controller in order to detect in the keil editor. due to that I have to use the lpc expresso the wake up the debug controller and then it is detedted in leil and then i can download the project . but still i am not able to debug every time . 

Let me check the debugging and then I will let you know the issue regarding the Keil project. Also you said that I can get the help from the support team for DSP library in LPC expresso from your support team. I rquest you to please resolve the issue of the DSP library in the project that you found issue in compilation.

I tried to port the DSP library in LPC expresso but not able to port since there are some limitation in ASM code of keil and LPC expresso compiler. The problem is with the code in birreversal.s file. Some initital line of code is not supported by LPC expresso compiler. Like that there are lot of issues which i need to check and revert.

The hard fault handler issue is resolved in LPC Expresso library but output is not proper as ou know. Kindly let me know how can I get the help from the support team regarding the DSP library issue for LPC4367  in LPC Expresso. 

Also send the latest library modified and issue resolved one so that I can add it in ny LPC expresso project.

Waiting for  your response.

Thanks,

Gaurav More

0 Kudos

3,599 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav,

     You don't need to download the code, because all that tested code is from your above post, I just test and summarize it, The linker is in the above post.

   You said: The problem regarding the debug of code or project in keil with DAP is that every time i have to wake upt the debug controller in order to detect in the keil editor.   Could you give me more details about it? Because I debug it, I didn't find the debug problem. Please give me some picture about the keil debug problem.

   Yes, about the LPCXpresso DSP problem, actually, after I contact with our LPCXpress engineer from internal email, he already reply you in this post, now, we just need to @ him.

Hi,   lpcxpresso_support‌ 

     We need the help about the LPC43XX DSP LIB LPCXpresso support, please check my summarize in Jun 19, 2018 8:39 PM.

   You can find, when we use the MDK newest DSP lib with MDK IDE, the Rfft is correct, but when use the LPCXpresso install path's DSP lib, now, we don't have the hardfault, but have the result correct problem, could you help to check it? Or can you tell us, how to import the newest DSP lib to LPCXpressso IDE without problem?

   


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,599 Views
gauravmore
Contributor III

Hi Kerry,

Any updates regarding the details and the request raised for Support team regarding the DSP library available in LPC expresso. kindly resolve the same ASAP since it is very urgent to exepedite the developement. since it is very easy to debug and create the project in LPC expresso.

Awiating your reply.

Thanks 

Gaurav More

0 Kudos

3,599 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gaurav More,

      Sorry for our later response, I also didn't get the reply in the last days, but don't worry now, I also make it works on my side.   

     Please check my test result:

  pastedImage_1.png

You can find the the output data is the same as the MDK now.

Now, let me tell you the details, I downloaded the newest DSP lib from ARM, the source code is:

https://github.com/ARM-software/CMSIS_5/archive/5.3.0.zip 

Then, I replace FFT_Code\CMSIS_DSPLIB_SRC\src\dspcode with the newest function code, and change the inc, inc_cmsis files with the new dsp lib, but I still didn't modify the LIB file, because we call the dsp source code directly, then it works correct now. If you want to use the lib, you also can use the newest ARM .lib.

Just as LPCX presso support said in the last post: DSP lib under LPCXpress IDE is very old, we can use the newest lib directly instead of the old DSP lib.

Anyway, I attach my project, and test it on your LPC4367 and check the result.

Any updated question, please kindly let me know, thank you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,599 Views
gauravmore
Contributor III

Hi kerry,

I have not recived any response from your side regarding the code which i have sent you for analysis for DSP functionality.

Kinldy provide the solution since i am not able to finalize the controller due to these issues and also let us know regarding the Keil compiler as to  how i can created muliticore product and compile and debug since in keil libraray it is working fine as the values are comming properly.

Waitng for you reply ASAP.

Request you to please coordinate with Support team since i feel they are not in sync with oour conversation and issue.

Thanks 

Gaurav More

0 Kudos