Using NRF52832 chip + freeRTOS development encounters the problem of getting stuck in idle tasks

I am developing a product that uses the chip of NRF52832 and runs FreeRTOS on the chip to manage my task list.
However, I found that the program would be stuck in the idle task, and it may be that the system had just started to run shortly or after ten or more hours of operation of the system.
I run the following code in vApplicationIdleHook:

void vApplicationIdleHook(void)
{
	__set_FPSCR(__get_FPSCR() & ~(0x0000009F));
	(void) __get_FPSCR();
	NVIC_ClearPendingIRQ(FPU_IRQn);
	if(uxTaskPriorityGet(xTaskGetIdleTaskHandle())!=0)
	{
		APP_ERROR_HANDLER(DEF_ERROR_THREADHEAPFAULT);
	}
}

It is found that he will randomly throw this Error code
Does anyone know what’s going on?

  • Might not help, but maybe try changing the FPU event clear to this (in case optimisation issue):

            volatile uint32_t fpscr;
            fpscr = __get_FPSCR();
            /*
             * Clear FPU exceptions.
             * Without this step, the FPU interrupt is marked as pending,
             * preventing system from sleeping. Exceptions cleared:
             * - IOC - Invalid Operation cumulative exception bit.
             * - DZC - Division by Zero cumulative exception bit.
             * - OFC - Overflow cumulative exception bit.
             * - UFC - Underflow cumulative exception bit.
             * - IXC - Inexact cumulative exception bit.
             * - IDC - Input Denormal cumulative exception bit.
             */
            __set_FPSCR(fpscr & ~0x9Fu);
            __DSB();  // or just __DMB();

Related