I have posed a question, "Function run in MCU generate noise to the analog circuit", before but at that time the question was not detailed enough. After several days` of testing, the problem is now more specific.
When I run a function with 600 Hz frequency, I can observe a set of noise (600 Hz, 1200 Hz, 1800 Hz, etc.). Here is the frequency spectrum:
After some tests, I think it is due to the improper decoupling of the VDD of the microcontroller. But I am not sure. I did another test. I found that when the capacitors (inside red circles) changes their value from 0.1 µF to 0.01 µF, the noise decreases.
And the noise after the change:
My question is:
Why would the noise decrease after the change? Is it due to the improper decoupling of the microcontroller? (but 0.1 µF is recommended in the STM32F4 datasheet).
Here is the PCB of those pins and capacitors: