# WP760x: 8KHz Output for Buzzer

**URL:** <https://forum.legato.io/t/wp760x-8khz-output-for-buzzer/3593>\
**Category:** Legato Application Framework\
**Created:** [August 27, 2018, 5:14am UTC](https://forum.legato.io/t/wp760x-8khz-output-for-buzzer/3593 "2018-08-27T05:14:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TAK\_G](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TAK\_G](https://forum.legato.io/u/TAK_G)\
**Post date:** [August 27, 2018, 5:14am UTC](https://forum.legato.io/t/wp760x-8khz-output-for-buzzer/3593/1 "2018-08-27T05:14:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JayM2M](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JayM2M](https://forum.legato.io/u/JayM2M)\
**Post date:** [September 5, 2018, 9:43am UTC](https://forum.legato.io/t/wp760x-8khz-output-for-buzzer/3593/2 "2018-09-05T09:43:17Z")

</div>

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:

> **[sx1509.pdf](https://cdn.sparkfun.com/datasheets/BreakoutBoards/sx1509.pdf)**
>
> 727.42 KB

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](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/](https://lore.kernel.org/patchwork/patch/612159/)  
Another way to do it:

> **[GitHub - ant9000/soft\_pwm: A kernel module for generating PWM signals](https://github.com/ant9000/soft_pwm)**
>
> A kernel module for generating PWM signals. Contribute to ant9000/soft\_pwm development by creating an account on GitHub.

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

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/dfrey/32/563_2.png) [@dfrey](https://forum.legato.io/u/dfrey)\
**Post date:** [September 5, 2018, 4:12pm UTC](https://forum.legato.io/t/wp760x-8khz-output-for-buzzer/3593/3 "2018-09-05T16:12:13Z")

</div>

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.
