WP760x: 8KHz Output for Buzzer

Hi,

My customer would like to output 8KHz waveform to ring buzzer from WP7605/8.

Q1: In this case, which API is better for it?
I think there are two solution.

  1. Use Timer API with Interrupt Handler.
  2. Use PCM API to use PCM_CLK and set it 8KHz.

Q2: In case of #2(PCM), which API should we set , le_audio_SetPcmSamplingRate() or le_audio_SetPcmSamplingResolution() ?
BTW, is it possible to set PCM_CLK 4KHz ?

Q3: Is there any sample project for such application?

–TAK

Hi,

Is it on mangOH Red hardware?

If yes then the embedded GPIO expander (SX1509) could be used to output PWM signals on selected pins through its LED driver feature.
Check datasheet of SX1509:

WP76xx by itself doesn’t have hardware PWM output.

If you just need to output clock signal (square waveform) at a selected frequency, it should be possible to do it in kernel by changing the function of a selected pin from GPIO to GP_CLK.
It is not an easy task and you will need to have some knowledge on Qualcomm MDM9x07 platform.
An example on Qualcomm APQ8016 chipset (you will have to adapt it for MDM9x07) is visible here:
https://github.com/Mani-Sadhasivam/linux-qcom/commit/629056dc11a3cbf0eb58be01e0d5c46fc93f3416

Regarding the software approach (bit-banging on GPIO):
It should be feasible for low frequencies but for efficiency reasons (accuracy and CPU load) it is recommended to implement it on kernel side.
See:
https://lore.kernel.org/patchwork/patch/612159/
Another way to do it:

Regarding the PCM approach:
PCM_CLK is the bit clock (2.048MHz).
But it should be possible to use the frame synchronization signal (PCM_SYNC) which is 8kHz by default.
PCM_SYNC can be set also to 16kHz by using le_audio_SetPcmSamplingRate() but it is not possible to set it to 4kHz (or any other values).

Jay

I believe the sx1509 is capable of producing an 8 kHz PWM signal, but the Linux kernel driver for the sx1509 doesn’t currently support the PWM features provided by the chip.