osTimerStart sometimes gives osErrorResource error

Hello all.

I have a FreeRTOS project on a Nucleo STMF429 development kit with the CMSIS V2 wrapper. I am occasionally getting osErrorResource complaints when I restart one-off timers with the osTimerStart function. I have checked my stack and heap and don’t believe i’m overflowing memory.

My timers are all created after the kernel starts but before their queue begins. Here is an example:

  /* create timers */
  ImuCalTimer = osTimerNew( ImuCalTimerCallback, osTimerOnce, NULL, NULL );
  ASSERT( ImuCalTimer != NULL );

  ImuMagPollTimer = osTimerNew( ImuMagPollTimerCallback, osTimerOnce, NULL, NULL );
  ASSERT( ImuMagPollTimer != NULL );

The osErrorResource error occurs after several iterations of timer based polling ie:

  // if polling, restart timer
  if( phIMU_global->PollingState == IMU_POLLING_STATE_ENABLED )
    osStatus = osTimerStart(ImuMagPollTimer, IMU_MAG_POLL_INTERVAL );
    ASSERT( osStatus == osOK );

  // allow next update to process if waiting
  osMutexRelease( IMUUpdateMutex );

The osTimerStart is a wrapper for xTimerChangePeriod, and the FreeRTOS error is set in queue.c at line 854 where it indicates the queue is full ie:

if( xTicksToWait == ( TickType_t ) 0 )
	/* The queue was full and no block time is specified (or
	the block time has expired) so leave now. */

	/* Return to the original privilege level before exiting
	the function. */
	traceQUEUE_SEND_FAILED( pxQueue );
	return errQUEUE_FULL;

I realize this is probably not enough sample code to be helpful, but the project is quite large and I can’t enter it all here. Let me know if some specific details would help troubleshoot.

I also realize FreeRTOS is not responsible for any wrappers of your OS, and I am sending a similar request to STM for that part.

Thank you

You might need to increase the priority of the timer task configTIMER_TASK_PRIORITY. If that’s not a good option for you, then you would need to increase configTIMER_QUEUE_LENGTH. See FreeRTOSConfig.h.

1 Like

You are a legend, thank you. I didn’t realize that the priorities were extended from 7 to 64 due to the wrapper… so my high priority timer task became one of the lowest. Thank you Jeff

1 Like