Shop OBEX P1 Docs P2 Docs Learn Events
Propeller — Parallax Forums

Propeller

dasmith6975dasmith6975 Posts: 6
edited 2015-06-07 18:58 in Propeller 1
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

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-07 16:38
    It's much easier to read code in the forum if you use code tags. Use "Reply With Quote" to see how I added code tags to your code.
    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
    

    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?
  • T ChapT Chap Posts: 4,223
    edited 2015-06-07 16:52
    I removed my response. My object is different from his so my reply was pointless.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-06-07 17:23
    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

    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?
  • dasmith6975dasmith6975 Posts: 6
    edited 2015-06-07 17:24
    do you know what illegal circular reference mean?
  • T ChapT Chap Posts: 4,223
    edited 2015-06-07 17:30
    I would start removing lines and see if you can find a single line that is the offender. Circular reference may often mean that one thing is referring to something else and you have a loop that is not allowed. You need to post that SWave object you are using.
  • Heater.Heater. Posts: 21,230
    edited 2015-06-07 18:00
    dasmith6975,
    do you know what illegal circular reference mean?
    I have never seen this error but I'm pretty sure the problem is to do with your OBJ sections.

    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:
    OBJ
    b: "b"
    
    PUB start
    
    File b.spin:
    OBJ
    a: "a"
    
    PUB start
    
    I don't even need to compile it, just open the file a.spin and it crashes!
  • Heater.Heater. Posts: 21,230
    edited 2015-06-07 18:08
    It's kind of interesting to compile a.spin and b.spin with openspin. It does not detect "circular reference but does bomb at too deep an object nesting level:
    $ openspin a.spin 
    Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2014 Parallax Inc. DBA Parallax Semiconductor.
    Version 1.00.71 Compiled on Nov 30 2014 07:40:47
    Compiling...
    a.spin
    |-b.spin
      |-a.spin
        |-b.spin
          |-a.spin
            |-b.spin
              |-a.spin
                |-b.spin
                  |-a.spin
                    |-b.spin
                      |-a.spin
                        |-b.spin
                          |-a.spin
                            |-b.spin
                              |-a.spin
                                |-b.spin
                                  |-a.spin
    a.spin : error : Object nesting exceeds limit of 16 levels.
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-06-07 18:58
    That's weird, since OpenSpin was based upon Chip's 86 asm code. This is something that Roy needs to know about.

    -Phil
Sign In or Register to comment.