Propeller
dasmith6975
Posts: 6
new to propeller usually an arduino person any way started using Microcontroller doing some of the projects to get use to controller, anyway on one of them keep getting illegal circular reference on square wave spin. need help!!!
CON
_clkmode = xtal1 + pll16x ' Crystal and PLL settings.
_xinfreq = 5_000_000 ' 5 MHz crystal x 16 = 80 MHz
OBJ
pst : "Parallax Serial Terminal" ' Serial communication object
sqw : "SquareWave" ' Square wave object
PUB go | detect
pst.Start(115200) ' Start Parallax Serial Terminal
repeat
sqw.Freq(2, 0, 38000) ' P2 IR LED flicker at 38 kHz
waitcnt(clkfreq/100 + cnt) ' Wait 10 ms
detect := ina[5] ' Check IR receiver
sqw.Freq(2, 0, 0) ' Turn off IR LED
' Cursor home, display label, detector state, clear to end of line.
pst.Str(String(pst#HM, "IR Detector = "))
pst.Dec(detect)
pst.ClearEnd
CON
_clkmode = xtal1 + pll16x ' Crystal and PLL settings.
_xinfreq = 5_000_000 ' 5 MHz crystal x 16 = 80 MHz
OBJ
pst : "Parallax Serial Terminal" ' Serial communication object
sqw : "SquareWave" ' Square wave object
PUB go | detect
pst.Start(115200) ' Start Parallax Serial Terminal
repeat
sqw.Freq(2, 0, 38000) ' P2 IR LED flicker at 38 kHz
waitcnt(clkfreq/100 + cnt) ' Wait 10 ms
detect := ina[5] ' Check IR receiver
sqw.Freq(2, 0, 0) ' Turn off IR LED
' Cursor home, display label, detector state, clear to end of line.
pst.Str(String(pst#HM, "IR Detector = "))
pst.Dec(detect)
pst.ClearEnd
Comments
I'm not sure how we can help you without access to the object "SquareWave." It's not in the Propeller Tool's library. Do you have a link?
If you download the Explorer binary into the Prop then you can just talk to it via your terminal and all that you want to do in your preceding code can just be typed/pasted in like this:
#P2 APIN 38 KHZ 10 ms 5 PIN@ MUTE PRINT" IR Detector = " . CR
It doesn't have to be all on one line but it also can be.
Or create a name for it and lock it into the Prop's EEPROM with:
pub IRDEMO #P2 APIN 38 KHZ 10 ms 5 PIN@ MUTE PRINT" IR Detector = " . CR ; BACKUP
Then any time you want to run it you type IRDEMO and it reports back.
Isn't that simple?
If you have a source file, call it "A.spin", that references another source file, "B.spin", which in turn references the original source file, "A.spin", then you have a circular reference.
Of course this can be more complex than just two files: A references B reference C reference D references A.
Wow! I just tried this with PropellerIDE. No error, it just crashed the IDE!
File a.spin: File b.spin: I don't even need to compile it, just open the file a.spin and it crashes!
-Phil