Sometimes, I think people ask too much of the PIC and expect it to do things when other external hardware exists that would do it better. But since you mailed me off-list to give you a solution, then here’s an obvious one you really should have thought of yourself... which is one reason I didn't reply to this thread originally.
Why not just calculate the period time of your requirement and write a routine to produce it?
123.4Hz has a period of 8.103mS, therefore it has a High of 4.052mS and a Low similarly. There will then be 1000/8.103=123.4 cycles produced in a second.
CounterA var Byte
TonePin var PortB.0
.. ..
‘
‘ Approximate 1 second burst of 123.4Hz
‘
BurstLoop:
For CounterA=0 to 123
High TonePin
PauseUS 4052
Low TonePin
PauseUS 4048
‘ slightly lower to account for approximate
‘ propogation delay through For-Next Loop
Next CounterA
Accuracy will depend on how good your PIC’s clock is. Use a Scope to ensure linearity of High and Low Pulses along with a Frequency Counter to check the result. Adjustments are made by obviously increasing or decreasing the appropriate pauses. I’ll let you do that.
Melanie
Bookmarks