I'm using Arduino nano and I'm struggling working with the DRV8870 IC on PWM mode.
When I use
analogWrite(_pin, duty_cycle); the motor makes weird noises.
I thought it's because of the PWM frequency so I tried to change it using
TCCR1B = TCCR1B & B11111000 | B00000011; but it didn't work out.
Texas Instruments wrote this in their pdf: "When using PWM, switching between driving and braking typically works best. For example, to drive a motor forward with 50% of the maximum RPM, IN1 = 1 and IN2 = 0 during the driving period, and IN1 = 1 and IN2 = 1 during the other period."