I'm using a generic Blue Pill with STM32F103C8, flashed with a generic PC13 maple dfu bootloader (not sure if fast or not).
My problem in short is that when trying to override yield() inside my sketch (no matter in which place regarding setup() and loop()), my sketch won't start. The setup() function doesn't start, and even USB CDC serial port doesn't show up (unknown device instead). This happens using both PlatformIO and Arduino Studio using the official stm32duino core. As soon as I upload the same code without yield() (even as an empty function), everythng starts working. I have checked it even on a simple blink sketch, so the surrounding code seems to make no difference.
Longer story about why I want to override yield() is, that I want to use a TM1637 display simultaneously with Accelstepper library. The display library uses delay function that looks like this:
Code: Select all
void TM1637Display::bitDelay()
{
delayMicroseconds(m_bitDelay);
}
This causes problems for Accelstepper, as run() is not called for at least 1ms, as usually more than 8 bits are transferred in a row.
I thought of using a similar concept as for delay(), and change the function to:
Code: Select all
void TM1637Display::bitDelay()
{
uint32_t start = micros();
do {
yield();
} while (micros() - start < m_bitDelay);
}
Code: Select all
void yield(void){
stepper_x.run();
stepper_y.run();
}
Do you have any thoughts on why would overriding yield() cause the whole program fail to start? I have checked my way of overriding yield() on Arduino Nano and it works OK. I have searched through the stm32duino core repository for any implementation of yield(), but again nothing except of a standard weak empty implementation. Can it be that it interferes with the bootloader?