Hi team:
I've been puzzled by a strange problem for a long time, when i use FOC motor control. It seems that the FOC control thread failed to be scheduled in real time. The code structure of ./apps/examples/foc/foc_float_thr.c can be simplified description is as follows: while (motor.mq.quit == false) { ...FOC control code... /* Get FOC device state */ ret = foc_dev_state_get(&dev); if (ret < 0) { PRINTF("ERROR: foc_dev_state_get failed %d!\n", ret); goto errout; } ...FOC control code... } where foc_dev_state_get will be periodic blocked by waiting semaphore, and ADC interrupt periodic give semaphore. My custom board is based on stm32f405 and my config about foc as shown below: CONFIG_EXAMPLE_FOC_PWM_FREQ=20000 CONFIG_EXAMPLE_FOC_NOTIFIER_FREQ=10000 CONFIG_EXAMPLE_FOC_CONTROL_PRIO=255 So, the FOC control code will be executed every 100us theoretically, In fact, this is true in most cases tested on real hardware, but there's sporadic unexpected states, that the execution interval between two FOC control is 120~170us, There's no effect when the motor speed is low, but when the motor speed is very high(up to 60000 erpm), this will cause serious problem, the motor may suddenly get stuck and burn. What puzzles me is the priority of FOC control thread already been set to the highest 255, and i have enabled the CONFIG_PRIORITY_INHERITANCE, why the FOC control threads was delayed so serious ? BTW, ther execution time of single FOC control loop is 60~70us, and there's 5 custom task in my case: Is my configuration incorrect or the real-time performance of nuttx can not meet the requirements? Does anyone else have the same problem? Best regard Zou