I am not really keen on Clocks but I need to feed a microphone device with a clock of 12MHz that should be generated generated in a Beaglbone AI and have an output in the GPIO so I can wire it to the ADC. I have no clue, where to start from. Just a script, changing the value?
Thanks in advance,
Not used the AI, but your best bet will be a PWM assuming it will go that high.
PRU or CLKOUT are also options.
And how do I use that? Need to configure it in the DTS?
For PWM check in /sys/class/pwm to see the pwms.
You may need to include a devicetree overlay at boot.
I don’t have the Ai so I don’t know exactly how the board is setup.
You may also have to export a PWM to use it.
If you see period, duty_cycle and enable entries in the pwm directories then you won’t need to export them.
then for whichever PWM you want to use do:
echo 84 > period
echo 42 > duty_cycle
echo 1 > enable
period sets the frequency. the value you write here is the period as measured in nanoseconds.
duty_cycle sets the duty cycle, again measured in nanoseconds. For a nice square wave clock this should be half the period value.
enable starts/stops the pwm.
for 12Mhz you need a time of 83.3333 ns, so 84 will be a little slower than 12Mhz. If you need exactly 12Mhz, you wont get that with the PWM.
If you want to use the PRU, you will need to write some code to toggle a gpio pin. Unless you can find and example that does this, I suggest not doing it this way.
I don’t know about CLKOUT. You may need to configure this in a dts file, however it may be configurable from somewhere is /sys
Assuming it is configurable in /sys, this should also be an easy option and may get you exactly 12Mhz