Page 1 of 1

buzzer tone

Posted: Sun Dec 14, 2025 11:41 am
by siliconchip
HI all
im trying to generate a tone using a buzzer, ive looked through the forum and found a flowchart intended for an arduino ive changed what i think needs changing for my target chip a pic 12f1572, however i cannot workout how to output the waveform to the output and if anything requires adding id appreciate any help to get this up and running if possible, thanks in advance
bob

Re: buzzer tone

Posted: Sun Dec 14, 2025 2:08 pm
by medelec35
Hi Bob.
The C code that was being used is only for AVR(as you correctly stated) as it's much more precise that current AVR PWM.
You will need to use the SetFrequency function of Flowcode's PWM component.
I have attached an untested example.
Note the SetFequency function should automatically set the duty to 50%

Re: buzzer tone

Posted: Sun Dec 14, 2025 2:37 pm
by siliconchip
hi Martin
as always thanks for the reply ive played around with it but i cant find how to output the waveform plus does it need the duty and period setting ??

cheers bob

Re: buzzer tone

Posted: Sun Dec 14, 2025 3:53 pm
by medelec35
Hi Bob.
No , should not require duty or period as it should be all set automatically by the SetFequency function.
Before going any further, have you tried the one second flasher to make sure micro is running at the correct speed?
If you have then I will check the SetFrequency on a different target device

Re: buzzer tone

Posted: Sun Dec 14, 2025 3:59 pm
by siliconchip
Hi martin
ive not tried in hardware yet just simulation
Cheers bob

Re: buzzer tone

Posted: Mon Dec 15, 2025 12:30 pm
by siliconchip
Hi Martin
i can confirm in hardware that config settings are correct and ive got a led flashing, as for the program there is no output ive changed the timer option of the pwm from FOSC to HFINTOSC and then LFINTOSC still no joy,
cheers bob