This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using cFFT library NRF_LOG stop with Hardfault_Handler

HI

SDK-15 - NRF52840

I'm using SAADC example of the SDK.

I read the ADC values and I make an matrix to calculate FFT using the CMSIS library..

the problem is when I print the data after using DSP library (FFT), the program stuck, in dissasembly window appear:

Before to use the Library, NRF_LOG works fine.

HardFault_Handler:
0x15ee: 0xe7fe B.N HardFault_Handler ; 0x15ee

I have the following code:

 for ( int y = 0; y < SAMPLES_IN_BUFFER; y++)
           {
             Incomplex[y*2]=vibdata[y];
             Incomplex[y*2+1]=0;
             NRF_LOG_RAW_INFO("%d,", Incomplex[y]);  
             NRF_LOG_FLUSH(); 
           }
 
    arm_cfft_q15(&RealFFT_Instance,(q15_t *)Incomplex,0,1);

    arm_cmplx_mag_q15((q15_t *)Incomplex,fftvibout,SAMPLES_IN_BUFFER);
         
    for ( int y = 0; y < SAMPLES_IN_BUFFER; y++)  
     {
         NRF_LOG_RAW_INFO("%d,", fftvibout[y]);  // ***** HERE the program STUCK in the dissasembler appear HardFault_Handler
         NRF_LOG_FLUSH(); 
     }    
         

I attached an debugger screen.

Thanks 

Ricardo

Parents
  • Dear Nordik Team

    Finally, i have spent a lot of time trying to fidn a solution, I got it..
    The error was the position of INICIALITACION OF THE INSTANCE FFT...(arm_cfft_instance_q15   RealFFT_Instance;   )

    Before initialization of the variable, it was located in the Saadc_callback function..


    void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
      ret_code_t err_code;
      int cycle=6;
    
      ******* HERE WAS THE INSTANCE FFT INICIALITATION ****** I moved to #defined zone of the program
      
      if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
      {
        
        memset(p_event->data.done.p_buffer, 0, sizeof p_event->data.done.p_buffer);
        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

    After, I moved it to at the begining of the program

    #include "nrf_log_default_backends.h"
    #include "arm_const_structs.h"
    #include <arm_math.h>
    
    #define SAMPLES_IN_BUFFER 1024//512
    
    volatile uint8_t state = 1;
    
    int e, value,  amp ;
    float soundVolMax, soundVolAvg, soundVolRMS, soundVolRMSflt;
    float soundVolMaxR, soundVolAvgR, soundVolRMSR, soundVolRMSfltR;
    float dB;
    int AmpMax = SAMPLES_IN_BUFFER;
    int MicSamples = SAMPLES_IN_BUFFER;
    float signalMin, signalMax, signalAvg;
    float difA,difB,difC;
    
    int16_t vibdata[SAMPLES_IN_BUFFER], Incomplex[SAMPLES_IN_BUFFER*2],fftvibout[SAMPLES_IN_BUFFER*2];  
    
    // HERE position 2
    arm_cfft_instance_q15   RealFFT_Instance;   // ***** HERE MOVED THE INICIALITATION  **** **
    
    
    
    static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0);
    static nrf_saadc_value_t     m_buffer_pool[2][SAMPLES_IN_BUFFER];
    static nrf_ppi_channel_t     m_ppi_channel;
    static uint32_t              m_adc_evt_counter;

    Another problem, I realized,  the result of the FFT function all time give me a different result, i saw it in the "Live watch" in the screen shot.

    But it corrected when the instance was moved to the beginning of the program.

    Best Regards

    Ricardo

Reply
  • Dear Nordik Team

    Finally, i have spent a lot of time trying to fidn a solution, I got it..
    The error was the position of INICIALITACION OF THE INSTANCE FFT...(arm_cfft_instance_q15   RealFFT_Instance;   )

    Before initialization of the variable, it was located in the Saadc_callback function..


    void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
      ret_code_t err_code;
      int cycle=6;
    
      ******* HERE WAS THE INSTANCE FFT INICIALITATION ****** I moved to #defined zone of the program
      
      if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
      {
        
        memset(p_event->data.done.p_buffer, 0, sizeof p_event->data.done.p_buffer);
        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

    After, I moved it to at the begining of the program

    #include "nrf_log_default_backends.h"
    #include "arm_const_structs.h"
    #include <arm_math.h>
    
    #define SAMPLES_IN_BUFFER 1024//512
    
    volatile uint8_t state = 1;
    
    int e, value,  amp ;
    float soundVolMax, soundVolAvg, soundVolRMS, soundVolRMSflt;
    float soundVolMaxR, soundVolAvgR, soundVolRMSR, soundVolRMSfltR;
    float dB;
    int AmpMax = SAMPLES_IN_BUFFER;
    int MicSamples = SAMPLES_IN_BUFFER;
    float signalMin, signalMax, signalAvg;
    float difA,difB,difC;
    
    int16_t vibdata[SAMPLES_IN_BUFFER], Incomplex[SAMPLES_IN_BUFFER*2],fftvibout[SAMPLES_IN_BUFFER*2];  
    
    // HERE position 2
    arm_cfft_instance_q15   RealFFT_Instance;   // ***** HERE MOVED THE INICIALITATION  **** **
    
    
    
    static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0);
    static nrf_saadc_value_t     m_buffer_pool[2][SAMPLES_IN_BUFFER];
    static nrf_ppi_channel_t     m_ppi_channel;
    static uint32_t              m_adc_evt_counter;

    Another problem, I realized,  the result of the FFT function all time give me a different result, i saw it in the "Live watch" in the screen shot.

    But it corrected when the instance was moved to the beginning of the program.

    Best Regards

    Ricardo

Children
No Data
Related