sduino icon indicating copy to clipboard operation
sduino copied to clipboard

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

Open dvhx opened this issue 1 year ago • 2 comments

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.

dvhx avatar Apr 11 '24 16:04 dvhx

can you provide the circuit connectiion

VimalO2 avatar Apr 18 '24 11:04 VimalO2

dac8830 png cropped

dvhx avatar Apr 18 '24 21:04 dvhx