Function run in MCU generate noise to the analog circuit
Maybe you need to have larger decoupling caps nearest to the microcontroller power pins, ro reduce the path length that is able to couple its signal to other PCB trace or wire.