Grove Speaker with FRDM K64F


I’m trying to play tones on the Grove Speaker Plus via FRDM K64F. The speaker is connected to the D3 pin on the Grove base shield and I’m attempting to use PwmOut.

However, the tone is very high and feeble even when I set the duty cycle to 50% (max volume).

PwmOut spkr(D3);

In main -
while(1) {
spkr.period(1.0/500.0); // 500hz period
spkr =0.5; //50% duty cycle - max volume
spkr=0.0; // turn off audio

Any solutions?

Thank you!