I am using SimpleFOC to drive motors with an stm32F446RETx microprocessor.
When I use alone BLDCMotor::loopFOC() it works.
When I use alone HAL_SPI_TransmitReceive() from STM32Cube HAL library it works.
But when I use both HAL_SPI_TransmitReceive() behave weirdly.
HAL_SPI_TransmitReceive() before adding motor_M1.loopFOC() at right. And HAL_SPI_TransmitReceive() after adding motor_M1.loopFOC() at left.
Are you controlling 2 motors from the same MCU? this can be difficult, and especially with I2C sensors your loop-time will be quite slow…
With regards to your question, there is no reason using loopFOC() should interfere with SPI. So if you are having this problem these can be some things to look for:
do you use the same pins for the motor or sensor as you are using for SPI?
are you in open-loop or closed loop mode? If you were using the sensor, you could try without the sensor (open loop) to see if the sensor reading is causing the problem
if there is nothing wrong with the setup and software configuration, then you could use an oscilloscope to check the SPI signal lines. With this you could check if there is an electrical problem that is causing interference between the PWM and the SPI, for example…