Electronic – H-bridge low side current sensing: Current signal with oscillation why

current measurementdc motorh-bridgelow-sidemotor controller

my problem is the following: I am using two DRV8842 H-bridge ICs to control 2 different brushed DC motors, my intention is to use a PI controller for the current loop. The schematic looks like this:
Schematic Motor Driver and low side current sensing

and the pcb layout:
Motor Driver Board

For the current sensing i am using the INA301 chip from texas instrument for low side sensing and a shunt resistor of 30 mOhm. To measure the current i use an ADC interrupt at the middle of the PWM pulse in order to take a measurement each time the transistors are closed. I noticed that for low duty cycle my current readings were higher than those when i increased the duty cycle (PWM frequency 20 KHz). When i checked the voltage signal in the resistor and after the INA301, i noticed there were oscillations in the signal as shown in the picture:
Current Signal for 10% duty cycle

The blue signal is measured directly at the shunt resistor terminals. And the input signal to the ADC looks like this for the case of 10% and 50% duty cycle:

Current PWM with 10% duty cycle
Current PWM with 50% duty cycle

The blue signals are the resistor voltage amplified by the INA301 and low pass filtered with a RC filter with cutoff frequency of ~1.3 MHz. As i am sampling at the middle of the pulse, for low duty cycles i read this peak value and not the steady state value. For a brushed DC motor i would have expected a current signal with a sawtooth like form, what could be causing this oscillations? Maybe my pcb layout is bad and has parasitic inductance and capacitance or is it due to the PWM modulation and i need to use some snubber circuit? Any ideas on what could be wrong or how to solve it will be appreciated. Thank you all in advance!

Regards,
Emmanuel

Best Answer

A wild stab in the dark - your oscilloscope probe does not use one of these: -

enter image description here

Switch mode power supplies are notorious at generating pulsing magnetic fields that can easily be picked up if you only used this: -

enter image description here

It's easily proven - connect earth croc clip to target board earth and connect probe tip to exactly the same spot - what do you see?