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

NRF52 Softdevice Crash - arm_sin_f32

Hi.

I'm using the arm_sin_f32 function to generate an array of sine wave values. However when this function gets called the softdevice crashes.

I've included:

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

Defined "ARM_MATH_CM4" in the preprocessor symbols.

I've also initialized

void FPU_IRQHandler(void)
{
    // Prepare pointer to stack address with pushed FPSCR register.
    uint32_t * fpscr = (uint32_t * )(FPU->FPCAR + 0x40);
    // Execute FPU instruction to activate lazy stacking.
    (void)__get_FPSCR();
    // Clear flags in stacked FPSCR register.
    *fpscr = *fpscr & ~(0x0000009F);
}

And made changes to the power_mange function

static void power_manage(void)
{
		#if (__FPU_USED == 1)
		__set_FPSCR(__get_FPSCR() & ~(0x0000009F)); 
		(void) __get_FPSCR();
		NVIC_ClearPendingIRQ(FPU_IRQn);
		#endif
	
		uint32_t err_code = sd_app_evt_wait();
		APP_ERROR_CHECK(err_code);
}

I've tried searching for similar problems, but I haven't found a fix yet.

Link to main.c Link to project

Parents
  • It seems that the code that stores sine array values doesn't work well with low frequency values and I have to rewrite that segment of the code.

    The issue isn't with the FPU or softdevice.

    The foor loop that used the arm_sin_f32 function made the array much larger than anticipated. That caused data to be stored at random places in the ram and that caused a hardfault. When the array was contained to it's max size the code worked.

    The code will be updated with a fix some time during next week.

Reply
  • It seems that the code that stores sine array values doesn't work well with low frequency values and I have to rewrite that segment of the code.

    The issue isn't with the FPU or softdevice.

    The foor loop that used the arm_sin_f32 function made the array much larger than anticipated. That caused data to be stored at random places in the ram and that caused a hardfault. When the array was contained to it's max size the code worked.

    The code will be updated with a fix some time during next week.

Children
No Data
Related