Link

Build flags

SimpleFOClibrary supports a few compiler options which might be interesting to advanced users. They are described below.

Available build flags

Build flags control the way the compiler generates the code for SimpleFOClibrary. Some are supported on all architectures, while some are MCU-architecture dependent.

FlagArchitectureDescription
SIMPLEFOC_DISABLE_DEBUGAllset this to disable the entire debugging code
SIMPLEFOC_PWM_ACTIVE_HIGHSTM32, RP2040, ESP32sets PWM polarity on phase PWM outputs - default is active high (true) but can be set to false for active low polarity. Affects both high and low side in 6-PWM mode (STM32, RP2040)
SIMPLEFOC_PWM_LOWSIDE_ACTIVE_HIGHSTM32, RP2040, ESP32sets PWM polarity on low side phase PWM outputs - default is active high (true) but can be set to false for active low polarity. Affects only low side FETs in 6-PWM mode. No effect in other modes.
SIMPLEFOC_PWM_HIGHSIDE_ACTIVE_HIGHSTM32, RP2040, ESP32sets PWM polarity on high side phase PWM outputs - default is active high (true) but can be set to false for active low polarity. Affects only high side FETs in 6-PWM mode. No effect in other modes.
SIMPLEFOC_STM32_DEBUGSTM32set to enable extra debug output for STM32 MCUs.
SIMPLEFOC_STM32_MAX_PINTIMERSUSEDSTM32maximum number of PWM pins configurable, default is 12 (up to 2x 6PWM, normally that’s plenty)
SIMPLEFOC_SAMD_DEBUGSAMD21 / SAMD51set to enable extra debug output for SAMD MCUs.
SIMPLEFOC_SAMD_MAX_TCC_PINCONFIGURATIONSSAMD21 / SAMD51maximum number of PWM pins configurable, default is 24 (for up to 4x6PWM, that should be enough ;-) )
SIMPLEFOC_SAMD51_DPLL_FREQSAMD21 / SAMD51expected frequency on DPLL, since we don’t configure it ourselves. Typically this is the CPU frequency. For custom boards or overclockers you can override it using this define. Default is 120000000
SIMPLEFOC_DEBUG_RP2040RP2040set to enable extra debug output on Raspberry Pico.
SIMPLEFOC_ESP32_USELEDCESP32force use of the LEDC PWM driver even on ESP32s that support MCPWM. Mainly useful for testing purposes, normally you would prefer MCPWM if it is available.
SIMPLEFOC_ESP32_HW_DEADTIMEESP32Select between MCPWM hardware deadtime and a software implementation allowing phase_state configuration. Defaults to hardware for being tested more.
SIMPLEFOC_TEENSY_DEBUGTeensy 3.x / 4.xSet to enable extra debug output for Teensy 3.x / 4.x MCUs.
SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUGTeensy 4Enables a simple debugging for low-side current sense interrupts which sets the pin 30 to high each time the ADC1 fires an interrupt.
SIMPLEFOC_TEENSY4_FORCE_CENTER_ALIGNED_3PWMTeensy 4Force center aligned 3PWM mode on Teensy 4. Normally 3PWM mode is not center aligned and the timers are not synchronized.