You'll remind this OSCCAL stuff 
As you want a specific (or close to) sound/frequency, you should (and if i remind you did) place this DEFINE OSCCAL_1K 1 line at the top of your code OR if you already know the OSCCAL value OSCCAL=YourValue
AND now you can play with the OSCCAL value to adjust/calibrate the frequency on each and every of your PIC if you have time to kill.
The few assembly line routine you have should look like...
Code:
@PlayTone
@ BSF _Piezo
PauseUs AVar
@ BCF _Piezo
PauseUs AVar
@ DECFSZ _Cycles,1
@ Goto PlayTone
.
.
.
wich is almost the same as
Code:
PlayTone:
High Piezo
PauseUs AVar
Low Piezo
PauseUs AVar
Cycles=Cycles-1
if Cycles!=0 then PlayTone
.
.
.
The problem with the PBP one, is when you loop many times to produce a longer tone duration, it introduce a longer delay between each LOW to HIGH transistion and do a kind of distortion in the produce sound... unpleasant to hear.
Another advantage of using those instead of SOUND is that you have a better frequency range. As i remind, Melanie already did a table of it... somewhere on this forum.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks