Current Sense Noise?

Hey there! I have a setup with a GM3506 motor, a MKS Dual FOC Plus V3.2, a AS5048A encoder, and a WeAct STM32G474 board. I’m programming in the Arduino environment. With this I’ve run into an issue tuning the current vector PIDs, which I believe I have traced down to it reacting to noisy data from the current sense amplifiers.

This is the current from a single phase of the motor spinning in open loop velocity mode, measured with both a current clamp on the phase wire (blue) and an oscilloscope probe on the current sense input pin on the STM32 board (yellow):

And this is what the STM32 itself sees in the same situation:

With the motor disabled it’s better, but still a tad wilder than I’d expect:

What would the typical place be to start debugging this? Filtering in hardware? Finding the noise source? Configuring the ADCs better?

For future reference - I ‘fixed’ it by running two of the STM32G4’s ADCs in continuous conversion oversampling mode, instead of the library just doing a single read every time:

Still feels like the setup I’m using could use some actual hardware filtering, and I wonder if it would be helpful if users could easily check their current reading noisiness through the SimpleFOC library. This was really messing up my current PID loops, while I have quite a ‘standard’ hardware setup, that just wasn’t working right.