tenbaht / sduino

An Arduino-like programming API for the STM8
http://tenbaht.github.io/sduino/
GNU Lesser General Public License v2.1
347 stars 213 forks source link

Mere presence of (even unused) function with PinName argument makes DigitalWriteFast slower 10x #159

Open dvhx opened 3 months ago

dvhx commented 3 months ago

I'm using STM32F103C8T6 blue pill. I'm bitbangin DAC8830. Everything works fine, the output is sawtooth at around 4kHz. But if I add this function:

void asdf(PinName zz) {
  digitalWriteFast(zz, LOW);
}

Even though it's not even used, the speed drops to 500Hz which is almost 10x slowdown.

fast.ino.txt - this is fast version slow.ino.txt - this is slow version DSC00304 - scope comparing fast and slow version

The only difference is really only the presence of one unused function. Of course in real code this function is used and does something but I was able to minimize the code to still cause the slowdown.

VimalO2 commented 3 months ago

can you provide the circuit connectiion

dvhx commented 3 months ago

dac8830 png cropped