Welcome! Log In Create A New Profile

Advanced

STM32F411 + TMC2208: softwareserial conflict with servo

Posted by mariov 
STM32F411 + TMC2208: softwareserial conflict with servo
March 08, 2021 05:59PM
Hello,

I have designed a custom board (not yet put online, and more of a general purpose stepper controller board than a printer controller) using a STM32F411CEU + 6x TMC2208. The TMC2208 serial ports are defined as software.
The board works, and so does the TMC2208 serial communication.
However, if I attach servos they do not work... unless I disable software serial and use the drivers as stand alone. I would like to use both servos and full featured TMC2208.
I then found read somewhere that SoftwareSerial causes problems with interrupts and interferes with the Servo library. Is this still the case or did I configure something wrong with the timers?

I also shuffled around the timer definitions in my board config:
#define STEP_TIMER      5
#define TEMP_TIMER      10
#define TIMER_SERIAL    TIM9
But servos still don't work.
TIMER_SERVO is defined in variant.h as TIM11, so no conflict. Other than TIM5, TIM10, TIM9 and TIM11, STM32F411CEU also has TIM0, TIM1, TIM2, TIM3, TIM4 and the various PWM used (such as servos) are connected to pins associated with these timers.

Same behaviour when compiling with either arduino or plaformio. Relevant part of my platfromio.ini:
[env:MVSC2]
platform = ${common_stm32.platform}
board = blackpill_f411ce
framework = arduino
build_flags = ${common_stm32.build_flags}
	-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
	-D USBCON
	-D HAL_PCD_MODULE_ENABLED
upload_protocol   = dfu

Is my only solution modifying TMCStepper to not use SoftwareSerial but some other library, or is the issue elsewhere entirely?
Re: STM32F411 + TMC2208: softwareserial conflict with servo
March 16, 2021 01:27PM
Ok so adding the following to my board config causes conflicts during compile
#define TIMER_SERVO TIM1
with the definition in variant.h. If I edit variant.h, then the servos work for TIMER_SERVO TIM1 and TIM3, but somehow don't work for TIM2.

As for redefining TIMER_SERVO without editing variant.h...
I tried #undefine in my board config, and also build_unflags in platformio.ini, neither work.
I am not sure what is going on here... somehow if TIMER_SERVO in variant.h isn't TIM1 or TIM3 (and is TIM2 or TIM11, didn't test others), regardless of how it is redefined later, servos won't work. The undefs do work, but something must get affected before it gets to that point, I am not familiar enough with platformio/marlin to know why.

Anyway, the solution to keep everything within marlin is to just put the variant files into Marlin/buildroot/share/PlatformIO/variants/Generic_F411Cx/ and modify the TIMER_SERVO in variant.h there.
Then add following to the env section in platfromio.ini:
extra_scripts       = pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
Sorry, only registered users may post in this forum.

Click here to login