due with motor shield - set PWM

Hi all,
This is my first post. I've done extensive research online and can't seem to figure out how to fix my problem.

I have an arduino due with an arduino motor shield and a 24V power supply for Vin. I'm running a 24V motor with a PWM from pin 3. The PWM frequency exiting the shield and going into my DC motor is at 1 kHz, which is extremely audible. Is there an easy way to change the PWM frequency so its >20kHz (outside audible range).

I've tried https://arduino-info.wikispaces.com/Arduino-PWM-Frequency
and changed

#define PWM_FREQUENCY 30000 in
C:\Program Files (x86)\Arduino\hardware\arduino\sam\variants\arduino_due_x

Any suggestions?
Should I be altering system files?


Jonathan Salfity

Okay figured out the problem for anyone looking at this...

Digging deep into the system files I found a header file in C:\Program Files x86)\Arduino\hardware\arduino\sam\variants\arduino_due_x named variant.h with a variable named PWM_Frequency and TC_Frequency. I noticed PWM_Frequency is set at 1000 and TC_Frequency is set at 1000, so it was a good clue. I first changed PWM_Frequency to 30000…. Nothing happened, still had annoying sound. I changed PWM_Frequency and TC_Frequency to 30000 and voila, no more audible sound. The scope shows the pwm signal to be at 30 kHz. I’m not sure what TC_Frequency stands for , but it seems to be important for PWM period.