PDA

View Full Version : Problem with Freqout in BS2_Functions



JohnBF
01-28-2007, 10:54 PM
I'm having trouble using the Frequout routine in Martin Hebel's BS2-like routines. I'm sure it's an obvious mistake but I can't figure it out. I wired a piezo speaker to pin 8, and it makes a nice tone with a simple routine that toggles the pin 8 output on and off rapidly. But the program below (the first four blocks copied from BS2_Functions as directed) compiles and runs without an error message, but produces no sound. Is the mistake obvious?

/John

CON
··· _clkmode = xtal1 + pll16x
··· _xinfreq = 5_000_000····················
VAR
··· Long stack1[50]······· ' Stack for 2nd BS2 Cog
OBJ
··· BS2 : "BS2_Functions"· ' Create BS2 Object
PUB Start | x
····· BS2.start (31,30)··· ' Initialize BS2 Object, Rx and Tx pins for DEBUG
PUB MakeSound
· BS2.FREQOUT(8, 500, 2500)······

Martin Hebel
01-28-2007, 11:11 PM
MakeSound is a separate routine that must be called from your Start routine, it's like a gosub. When Start is done - no other code - the cog shuts down unless something else was called.




CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
Long stack1[50] ' Stack for 2nd BS2 Cog
OBJ
BS2 : "BS2_Functions" ' Create BS2 Object
PUB Start | x
BS2.start (31,30) ' Initialize BS2 Object, Rx and Tx pins for DEBUG
MakeSound

PUB MakeSound
BS2.FREQOUT(8, 500, 2500)


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

Post Edited (Martin Hebel) : 1/28/2007 4:59:37 PM GMT

JohnBF
01-29-2007, 12:04 AM
Got it. Thanks! /John