I don’t know if you have seen Sergey’s blog but in there is a post on how to program the GPIO from Linux and there is a section for the PWM check this link: http://www.malinov.com/Home/sergey-s-blog/intelgalileo-programminggpiofromlinux It’s a little different from your approach but it might help you, since you are able to set the period and duty cycle of the signal easily. I hope this suit your needs
If you want a 1.6kHz wave that is a 625 microsecond period or 626000 nanoseconds. So for the Linux method you would use these commands. (assuming a 50% duty cycle)
echo -n "625000" > /sys/class/pwm/pwmchip0/pwm3/period
echo -n "312500" > /sys/class/pwm/pwmchip0/pwm3/duty_cycle
to put this into an Arduino sketch, you can just surround the Linux command with the system call:
system("echo -n "625000" > /sys/class/pwm/pwmchip0/pwm3/period");
system("echo -n "312500" > /sys/class/pwm/pwmchip0/pwm3/duty_cycle");
You also might be interested in Mikal's servo fix. Releases · mikalhart/galileo-Servo · GitHub It allows you to use the Arduino servo command, which also allows you to adjust the period of the PWM signals. It is essentially doing what you want to do, but just setting up a different frequency.
Sir! Could you tell me how to use Arduino call the Linux command????
system("echo -n ""625000"" > /sys/class/pwm/pwmchip0/pwm3/period");
system("echo -n ""312500"" > /sys/class/pwm/pwmchip0/pwm3/duty_cycle");
This seems great ! I just add them in where I want to change the frequency?
And what is "system()"??? a funtional to call Linux command???
Thank your!!! Your help would be greaaaaaaatly appreciated!