Shop OBEX P1 Docs P2 Docs Learn Events
WAITPEQ questions [ WAITPEQ now working ] - Page 2 — Parallax Forums

WAITPEQ questions [ WAITPEQ now working ]

2»

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-19 01:54
    Harley,

    PAR points to SBPt in hub memory. Whatever SBPt equals at any given instant is what your prgram will read into BAcomp. In the instant after that value becomes $0001_0000, and before the LSB and MSB of the address are ORed in, that's what the cog with the WAITPEQ will read and will start looking for: an address of zero. It's not going to wait for you to finish constructing the address. That's why I suggested using another variable to construct the value that will then get assigned to SBPt in one fell swoop.

    -Phil
  • HarleyHarley Posts: 997
    edited 2009-06-19 03:06
    Thanks Phil,

    I'll try your suggestion tomorrow.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • HarleyHarley Posts: 997
    edited 2009-06-19 18:28
    @ Phil,

    I tried using another variable rather than SBPt, but no change and no workee.

    BTW, I never noticed any but the valid breakpoint values appearing that would cause exit of the ':loop' loop. Doesn't mean it never could happen, but never noticed.

    I gotta find a new direction to punt again. Thanks for the help. I will post when this WAITPEQ problem is resolved. yeah.gif <<=== I like that little guy!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-19 20:07
    Harley,

    Can you post your new code? Something just ain't right here.

    -Phil
  • HarleyHarley Posts: 997
    edited 2009-06-19 21:32
    Phil,

    Here's the new Spin stuff. Used BPt as the new variable; no changes needed in the asm cog.

    '*******************************
    '*  Control_2Prop2  v 0.1      *    mod  11:10 am  19 Jun.2009 
    '*  (C) 2007 h.a.s. designn    *
    '*******************************  ViewPort = v 4.1.1 , PASD = v 0.3 latest versions
    CON
      _clkmode      = xinput + pll16x
      _xinfreq      = 5_000_000     ' ext. clock @ 5 MHz on pin 30 from Prop#1, PLL=16x
      Prop_Tx       = 22            ' Data to Prop1, pin 27/A22
      Prop_Rx       = 23            ' Data from Prop1, pin 28/A23
      Prop_Baud     = 115_200       ' for Prop1 <=> Prop2 communications
    '  maskF0        = $0000_00F0    ' 2nd lsb nybl mask                    WHERE USED ???
      BM1 = 1 << 16                       ' Kuroneko code 
      time = $1FB                       ' Kuroneko code 
    VAR
      long stack[noparse][[/noparse]250], rxpin,  txpin, c, rxbyte, rxcheck, txbyte, BPt 
      long PodCntl, SBPt, CmdP2, CmdVP, id, dataReg, statReg, keyReg, AdDaStReg 
      long triggermask, triggerstate, NyblReg, BAbusReg, n, Prop2Reg, INTRPT, BAid 
      long  storage                       ' Kuroneko code 
    OBJ       
      PropSer       : "FullDuplexSerial"     ' for Prop1/Prop2 serial communications
      vp            : "Conduit"              ' transfers ViewPort data to/from PC - ver 2.0
      qs            : "QuickSample"          ' VP captures INA, variables, +1 cog @ 20 MHz
    '  dbg           : "PasDebug"    '<== use for PASD debugger (MUST include .binary file)
    '**************************************************************************************
    '  Prop#2: handles BAbus address comparator, interrupt 'logic', other Pod i/f signals. 
    '  Connects to Prop1 via rx/tx pins, and both Props connect to a 'Pod' board.
    '****email lc/37cc594a*****************************************************************
    PUB Main|frame[noparse][[/noparse]400]
      vp.register(qs.sampleINA(@frame,1))  '1 cog samples INA at 20 MHz = NEW VP commands
      vp.config(string("var:io,PodCntl,SBPt,CmdP2,CmdVP,id"))           ' VARs to display 
      vp.config(string("lsa:view=io,timescale=500ns,trigger=io[noparse][[/noparse]16]r"))  ' init lsa.display
      vp.config(string("edit:SBPt(mode=text),CmdVP(mode=text)"))        ' VARs to edit
      vp.config(string("start:lsa"))
      vp.share(@PodCntl,@id)  'share memory from 'PodCntl' to 'id'  END of VP init <<===
       
      PropSer.start(Prop_Rx, Prop_Tx, %0000, Prop_Baud)      ' sets comm w/Prop1
      id := cognew(@CntlP2,@CmdP2)      ' sets up Control pg#2 'logic' for CntlP2; CmdP2@PAR
    '  id := cognew(@entry,@CmdP2)      ' this sets up Control pg#2 'logic' for PASD
      id := cognew(@BAbusRd,@BPt)      ' SBPt value @ PAR for BAbusRd
    '  id := cognew(@entry,@BPt)       ' set up logic for PASD
      BAid := id                        ' save cog# for SBPt stop/restart
    '  id := dbg.start(31,30,@entry)    '<---- Add for PASD Debugger <<===
    ''PUB init
    '  storage := BM1 | $ABCD                       ' Kuroneko code 
    '  id := cognew(@trigger, @storage)                       ' Kuroneko code 
    ''  id := cognew(@entry,@storage)       ' set up logic for PASD
    ''  repeat  
    
      repeat  ' Main Loop ************ deals with signals between Prop#1 and Pod *********
        if (c := PropSer.rxcheck) <> -1      ' check for Prop#1 command and data
          Prop2Prop1                         '(Pod i/f via assembly rather than Spin cogs)
    '*************************************************************************************
    PRI Prop2Prop1             ' process Prop #2 commands from Prop#1
      if (c & $C0) == $C0           ' test if is a valid 'Control Pg 2' command
        CmdVP := c                  ' save copy for Viewport use
        CmdP2 := c                  '  if so, set variable CmdP2 (asm picks up in 'Cmd')
      case c
        $80 :                       ' used during Init; transfers 'title', Chipver and #cogs
          PropSer.tx(c)             ' echo that command value for Prop#1 'handshake'
          waitcnt(8000_000 + cnt)   ' wait about 100 ms  IS THIS TIMING RIGHT (below too) ???
          PropSer.str(@title2a)     ' send first text 'title' to Prop#1
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.str(@title2b)     ' send 2nd 'title'
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.tx(CHIPVER + $30) ' send ChipVersion
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.tx(id)            ' send #cogs used     
        $81 :                       ' looptest Prop#2
          PropSer.tx(c)             ' echo command
          repeat
            c := PropSer.rxcheck    ' check for loop test value
          while c == -1
          PropSer.tx(c)             ' return 'loop test value'
    ' $82 : ' - unused
        $83 :                       ' returns Breakpoint address to Prop##1
          SBPt := $0001_0000        ' set bit 16 true -- get ready to set Breatpoint value
          repeat                    ' 
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | (c << 8)   ' store HI byte of BreakPoint register
          repeat   
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | c          '  add LO byte
          BPt := SBPt
          
          PropSer.tx($83)           ' let Prop#1 display BPt bytes held in Prop#2 (comment out to 84)
          c := (SBPt >> 24) & $FF   ' get ms byte, return to Prop#1; now return as 4 bytes
          PropSer.tx(c)
          c := (SBPt >> 16) & $FF   ' get 2nd ms byte
          PropSer.tx(c)
          c := (SBPt >> 8) & $FF    ' get 2nd ls byte
          PropSer.tx(c)
          c := SBPt & $FF           ' get ls byte
          PropSer.tx(c)     
        $84 :                       ' returns Pod control bits
          PropSer.tx(c)
          c := INA                  ' get Prop#2 pin states
          PodCntl := (c >> 24 ) & $7      ' only get lower 3 bits of ms byte
          PropSer.tx(PodCntl)       ' send to Prop#1
    ' $85..$8F and $92..$FF codes unused; codes $000 ,, $6F for D/K communications
        $90 :                       ' returns $90 code and a count each time D/K RUN pressed 
          PropSer.tx(c)             ' echo '90' code
          PropSer.tx(n)             ' send 'count', then increment it
          n++      
        $91 :                        ' unused
          COGSTOP(BAid)                                     ' stop that cog
          waitcnt(40_000_000 + cnt)                         ' wait about 1/2 sec  ???      
          BAid := COGNEW(@BAbusRd,@SBPt) ' sets up Control pg#2 'logic' for CntlP2; CmdP2@PAR
    '************************  End of Spin code, next Assembly  *************************
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-19 21:40
    Your last line still uses @SPBt in the cognew.

    -Phil
  • HarleyHarley Posts: 997
    edited 2009-06-19 22:58
    I don't know what happened. I'm using Parallel's on a iMac and it or Windows crashes too often; I suspect Bill Gates is tinkering with Windows still. This Spin code should be the latest.

    '*******************************
    '*  Control_2Prop2  v 0.1      *    mod  11:10 am  19 Jun.2009 
    '*  (C) 2007 h.a.s. designn    *
    '*******************************  ViewPort = v 4.1.1 , PASD = v 0.3 latest versions
    CON
      _clkmode      = xinput + pll16x
      _xinfreq      = 5_000_000     ' ext. clock @ 5 MHz on pin 30 from Prop#1, PLL=16x
      Prop_Tx       = 22            ' Data to Prop1, pin 27/A22
      Prop_Rx       = 23            ' Data from Prop1, pin 28/A23
      Prop_Baud     = 115_200       ' for Prop1 <=> Prop2 communications
    '  maskF0        = $0000_00F0    ' 2nd lsb nybl mask                    WHERE USED ???
      BM1 = 1 << 16                       ' Kuroneko code 
      time = $1FB                       ' Kuroneko code 
    VAR
      long stack[noparse][[/noparse]250], rxpin,  txpin, c, rxbyte, rxcheck, txbyte, BPt 
      long PodCntl, SBPt, CmdP2, CmdVP, id, dataReg, statReg, keyReg, AdDaStReg 
      long triggermask, triggerstate, NyblReg, BAbusReg, n, Prop2Reg, INTRPT, BAid 
      long  storage                       ' Kuroneko code 
    OBJ       
      PropSer       : "FullDuplexSerial"     ' for Prop1/Prop2 serial communications
      vp            : "Conduit"              ' transfers ViewPort data to/from PC - ver 2.0
      qs            : "QuickSample"          ' VP captures INA, variables, +1 cog @ 20 MHz
    '  dbg           : "PasDebug"    '<== use for PASD debugger (MUST include .binary file)
    '**************************************************************************************
    '  Prop#2: handles BAbus address comparator, interrupt 'logic', other Pod i/f signals. 
    '  Connects to Prop1 via rx/tx pins, and both Props connect to a 'Pod' board.
    '****email lc/37cc594a*****************************************************************
    PUB Main|frame[noparse][[/noparse]400]
      vp.register(qs.sampleINA(@frame,1))  '1 cog samples INA at 20 MHz = NEW VP commands
      vp.config(string("var:io,PodCntl,SBPt,CmdP2,CmdVP,id"))           ' VARs to display 
      vp.config(string("lsa:view=io,timescale=500ns,trigger=io[noparse][[/noparse]16]r"))  ' init lsa.display
      vp.config(string("edit:SBPt(mode=text),CmdVP(mode=text)"))        ' VARs to edit
      vp.config(string("start:lsa"))
      vp.share(@PodCntl,@id)  'share memory from 'PodCntl' to 'id'  END of VP init <<===
       
      PropSer.start(Prop_Rx, Prop_Tx, %0000, Prop_Baud)      ' sets comm w/Prop1
      id := cognew(@CntlP2,@CmdP2)      ' sets up Control pg#2 'logic' for CntlP2; CmdP2@PAR
    '  id := cognew(@entry,@CmdP2)      ' this sets up Control pg#2 'logic' for PASD
      id := cognew(@BAbusRd,@BPt)      ' SBPt value @ PAR for BAbusRd
    '  id := cognew(@entry,@BPt)       ' set up logic for PASD
      BAid := id                        ' save cog# for SBPt stop/restart
    '  id := dbg.start(31,30,@entry)    '<---- Add for PASD Debugger <<===
    ''PUB init
    '  storage := BM1 | $ABCD                       ' Kuroneko code 
    '  id := cognew(@trigger, @storage)                       ' Kuroneko code 
    ''  id := cognew(@entry,@storage)       ' set up logic for PASD
    ''  repeat  
    
      repeat  ' Main Loop ************ deals with signals between Prop#1 and Pod *********
        if (c := PropSer.rxcheck) <> -1      ' check for Prop#1 command and data
          Prop2Prop1                         '(Pod i/f via assembly rather than Spin cogs)
    '*************************************************************************************
    PRI Prop2Prop1             ' process Prop #2 commands from Prop#1
      if (c & $C0) == $C0           ' test if is a valid 'Control Pg 2' command
        CmdVP := c                  ' save copy for Viewport use
        CmdP2 := c                  '  if so, set variable CmdP2 (asm picks up in 'Cmd')
      case c
        $80 :                       ' used during Init; transfers 'title', Chipver and #cogs
          PropSer.tx(c)             ' echo that command value for Prop#1 'handshake'
          waitcnt(8000_000 + cnt)   ' wait about 100 ms  IS THIS TIMING RIGHT (below too) ???
          PropSer.str(@title2a)     ' send first text 'title' to Prop#1
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.str(@title2b)     ' send 2nd 'title'
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.tx(CHIPVER + $30) ' send ChipVersion
          waitcnt(800_000 + cnt)    ' wait about 10 ms                            ???
          PropSer.tx(id)            ' send #cogs used     
        $81 :                       ' looptest Prop#2
          PropSer.tx(c)             ' echo command
          repeat
            c := PropSer.rxcheck    ' check for loop test value
          while c == -1
          PropSer.tx(c)             ' return 'loop test value'
    ' $82 : ' - unused
        $83 :                       ' returns Breakpoint address to Prop##1
          SBPt := $0001_0000        ' set bit 16 true -- get ready to set Breatpoint value
          repeat                    ' 
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | (c << 8)   ' store HI byte of BreakPoint register
          repeat   
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | c          '  add LO byte
          BPt := SBPt
          
          PropSer.tx($83)           ' let Prop#1 display BPt bytes held in Prop#2 (comment out to 84)
          c := (SBPt >> 24) & $FF   ' get ms byte, return to Prop#1; now return as 4 bytes
          PropSer.tx(c)
          c := (SBPt >> 16) & $FF   ' get 2nd ms byte
          PropSer.tx(c)
          c := (SBPt >> 8) & $FF    ' get 2nd ls byte
          PropSer.tx(c)
          c := SBPt & $FF           ' get ls byte
          PropSer.tx(c)     
        $84 :                       ' returns Pod control bits
          PropSer.tx(c)
          c := INA                  ' get Prop#2 pin states
          PodCntl := (c >> 24 ) & $7      ' only get lower 3 bits of ms byte
          PropSer.tx(PodCntl)       ' send to Prop#1
    ' $85..$8F and $92..$FF codes unused; codes $000 ,, $6F for D/K communications
        $90 :                       ' returns $90 code and a count each time D/K RUN pressed 
          PropSer.tx(c)             ' echo '90' code
          PropSer.tx(n)             ' send 'count', then increment it
          n++      
        $91 :                        ' unused
          COGSTOP(BAid)                                     ' stop that cog
          waitcnt(40_000_000 + cnt)                         ' wait about 1/2 sec  ???      
          BAid := COGNEW(@BAbusRd,@SBPt) ' sets up Control pg#2 'logic' for CntlP2; CmdP2@PAR
    '************************  End of Spin code, next Assembly  *************************
    DAT           ORG       0 
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-19 23:06
    Harley,

    But you've still got @SPBt in the last cognew, which means the code is not entirely fixed.

    -Phil
  • HarleyHarley Posts: 997
    edited 2009-06-19 23:33
    Aargh!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • HarleyHarley Posts: 997
    edited 2009-06-20 00:02
    Thanks Phil,

    Eureka! It seems to be working with that last change. Once a breakpoint is set, that no match occurs, the cog is stopped and restarted. That last one would wouldn't be effective any longer the way I missed it.

    And when viewed in ViewPort, if one doesn't display enough events, it may appear to hang when it actually didn't; exiting off screen to the right. So now I suppose using another/second variable to pass info to PAR is the fix needed for the other two cogs in the two Props.

    If a variable isn't built up the way I am doing it, say only a byte being used, does one still need to 'isolate' the PAR variable? I'm not clear the full explanation passing a variable to a asm cog. I suppose there might be some documentation beyond the Prop manual on this subject?

    Thanks again Phil. I owe you another one. yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-20 01:46
    Yay!

    -P.
  • HarleyHarley Posts: 997
    edited 2009-06-20 20:58
    For those who've not followed this too closely, PAR was being loaded with SBPt, but I'd missed the point of SBPt being constructed from a bit and two bytes with the following code. The last line solved the problem. Passing the FULL value once rather than in three instances.
        $83 :                       ' returns Breakpoint address to Prop##1
          SBPt := $0001_0000        ' set bit 16 true -- get ready to set Breatpoint value
          repeat                    ' 
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | (c << 8)   ' store HI byte of BreakPoint register
          repeat   
            c := PropSer.rxcheck
          while c == -1
          SBPt := SBPt | c          '  add LO byte
          BPt := SBPt
    


    Thanks to Phil Pilgrim for spotting my error in thinking (or lack of thinking it out fully). Yeah, I made a mistake ONCE! yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
Sign In or Register to comment.