FreeRTOS based PMSM Sensorless Control application available

Showing results for 
Search instead for 
Did you mean: 

FreeRTOS based PMSM Sensorless Control application available

NXP Employee
NXP Employee

Dear all,


Let me inform you that new application note AN5309 Sensorless PMSM Field-Oriented Control on Kinetis KV31 with FreeRTOS & eGUI is fully available on NXP web pages including application software AN5309SW.



AN5309SW V1.0.0


  • Supported HW platform: FRDM-MC-LVPMSM + FRDM-KV31F + Arduino™ R3-compatible LCD TFT
  • Supported MCUs: KV31
  • Main fetaures:
    • Sensorless field-oriented control of PMSM
    • FreeRTOS integration to time-critical  motor control application
    • Interrupt management of motor control and RTOS tasks
    • RTOS task scheduling
    • LCD TFT controlled using eGUI


The application is based on PMSM reference project and can be easily ported among supported MCU platforms.

Supported IAR and KDS IDEs


Please let us know if you need more details about the AN5309.



Kind regards,


SW MC Library team.

Labels (1)
0 Kudos
2 Replies

NXP Employee
NXP Employee

Hello @gusarambula

the CPU load in this example has been measured the most probably using Systick timer and macros.

Following code is taken from MCUX SDK Motor control examples.


/* CPU load measurement using Systick*/
uint32_t g_ui32NumberOfCycles = 0;
uint32_t g_ui32MaxNumberOfCycles = 0;

/* CPU load measurement SysTick START / STOP macros */
#define SYSTICK_START_COUNT() (SysTick->VAL = SysTick->LOAD)
#define SYSTICK_STOP_COUNT(par1) uint32_t val = SysTick->VAL; uint32_t load = SysTick->LOAD; par1 = load - val

*@brief SysTick initialization for CPU cycle measurement
*@param none
*@return none
void BOARD_InitSysTick(void)
/* Initialize SysTick core timer to run free */
/* Set period to maximum value 2^24*/
SysTick->LOAD = 0xFFFFFF;

/*Clock source - System Clock*/
SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;

/*Start Sys Timer*/
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;


/* Start CPU tick number couting */

/* sw routines to be measures */

/* stop CPU tick number couting and store actual and maximum ticks */
g_ui32MaxNumberOfCycles = g_ui32NumberOfCycles>g_ui32MaxNumberOfCycles ? g_ui32NumberOfCycles : g_ui32MaxNumberOfCycles;





NXP TechSupport
NXP TechSupport

Hello @pavelsustek,

We have a customer asking if there are more details available on how the CPU was measured for AN5309.

It was my understanding from other AN that IAR was used to calculate the CPU Usage. Is that correct? Would you please provide more information on how to replicate the measurements using the available SW for AN5309? Any insights on how these CPU usage data will be very much appreciated.


0 Kudos