Is it possible to produce audio square wave on PWM pin?

When the PWM pin of AB02S connects to a piezo electric speaker, can we produce variable audio sound such as 200Hz to 10kHz? The following code produces 90Hz. The PWM circuit of AB02S seems different than in Hardware PWM in CubeCell-1/2AA.

uint32_t div_2nd = 0xffff;

setup() {
setPWM_Frequency(PWM_CLK_FREQ_12M);
setPWM)CONPAREPeriod(div_2nd);
pinMode(PWM1, OUTPUT);
}

Sound_test()
{
analogWrite(PWM1, div_2nd / 2);
}

I am testing on the latest git repo. code.

1 Like