Anyone used SETPAT & WAITPAT ?

I expected this to fall straight thru with either MODCZ (not sure which way round the Z works for ==)
But neither fall thru'.
                waitx   ##_clockfreq
                
                mov     match,inb
                and     match,mask
'               modcz   _set,_clr         '  C & NZ     ' INB 
                modcz   _set,_set         '  C &  Z     ' INB
                setpat  mask,match
                waitpat                                
                ...                                

match           long    $00000000         
mask            long    $C0000000
Obviously I am missing something, but what???
My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
Website: www.clusos.com
P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
P2: Tools & Code , Tricks & Traps

Comments

  • I think you need to specify wcz with the modcz, otherwise it's basically a nop.
  • jmgjmg Posts: 14,152
    edited 2019-03-01 - 04:37:21
    Dave Hein wrote: »
    I think you need to specify wcz with the modcz, otherwise it's basically a nop.

    Hmm, is the users intention not already clear and unambiguous ?
  • Thanks Dave :smiley:
    That will be it!
    My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
    P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
    P2: Tools & Code , Tricks & Traps
  • Interesting...

    A trigger event is required to fire the waitpat.
    I thought with the P1 that a waitpeq/waitpne would pass immediately if the condition was met.
                    mov     match,inb
                    and     match,mask
                    xor     match,mask                      ' invert the SI=P31 pin
                    
    '               modcz   _clr,_set                   wcz ' NC & Z  (INA & D) == S
    '               modcz   _clr,_clr                   wcz ' NC & NZ (INA & D) != S
                    modcz   _set,_set                   wcz '  C & Z  (INB & D) == S
    '               modcz   _set,_clr                   wcz '  C & NZ (INB & D) != S
                    setpat  mask,match
                    waitpat                                 ' wait for activity on SI=P31
    
    My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
    P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
    P2: Tools & Code , Tricks & Traps
  • jmgjmg Posts: 14,152
    Does it need that and in the second line ?

    Docs say
    Set pin pattern for PAT event. C selects INA/INB, Z selects =/!=, D provides mask value, S provides match value.
    ie the mask in D, should not need the match also masked elsewhere ?

  • jmg wrote: »
    Dave Hein wrote: »
    I think you need to specify wcz with the modcz, otherwise it's basically a nop.

    Hmm, is the users intention not already clear and unambiguous ?

    Not quite; the instruction doesn't really say which of c and z should be updated (c, z, or both).

    However, if neither is updated that's probably a bug. fastspin will issue a warning in this case. I don't think PNut warns about it, but perhaps that would be a useful addtion.

    FlexGUI, a GUI for programming the P1 and P2 in Spin, PASM, BASIC, and C.
    Help support its development at Patreon or PayPal.
  • jmg wrote: »
    Does it need that and in the second line ?

    Docs say
    Set pin pattern for PAT event. C selects INA/INB, Z selects =/!=, D provides mask value, S provides match value.
    ie the mask in D, should not need the match also masked elsewhere ?

    This is the test done for the event (C and Z are flag states and D and S are register values from when SETPAT executed):

    event = (((C ? INB : INA) & D) == S) ^ !Z
  • From what i saw, if the value doesn’t change, then no event will be created.
    ie if you are looking for a value, and that value exists prior to performing the waitpat, then waitpat never returns.
    I don’t think the P1 works this way. It just tests to see if the condition is met.
    My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
    P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
    P2: Tools & Code , Tricks & Traps
  • The event occurs when the pattern is detected. If the pattern is present from the beginning, there is no event.
  • Cluso99 wrote: »
    I don’t think the P1 works this way. It just tests to see if the condition is met.

    Totally. WAITPEQ and WAITPNE

    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • Cluso99Cluso99 Posts: 15,549
    edited 2019-03-01 - 17:00:00
    cgracey wrote: »
    The event occurs when the pattern is detected. If the pattern is present from the beginning, there is no event.
    So we have to do an additional check first now to see if the condition is met, and skip the waitpat if it’s already met?
    My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
    P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
    P2: Tools & Code , Tricks & Traps
  • tomcrawfordtomcrawford Posts: 1,071
    edited 2019-03-01 - 17:11:01
    Now that I think about it:

    Actually, for the 360 feedback servo, I have to measure a high period and the following low period. So on P1, I do a WAITPxx for a low, followed by a WAITPxx for a high to be certain I am measuring the whole high period (followed by another WATPxx for the end of the high period, etc). Basically, I am LOOKING for edges, so the P2 should work out better. Plus I think I can implement a timeout for the case where the servo died without feedback.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • Now that I think about it:

    Actually, for the 360 feedback servo, I have to measure a high period and the following low period. So on P1, I do a WAITPxx for a low, followed by a WAITPxx for a high to be certain I am measuring the whole high period (followed by another WATPxx for the end of the high period, etc). Basically, I am LOOKING for edges, so the P2 should work out better. Plus I think I can implement a timeout for the case where the servo died without feedback.

    There is a state-measuring smart pin mode that alternately measures high and low times, without missing a clock.
  • jmgjmg Posts: 14,152
    cgracey wrote: »
    The event occurs when the pattern is detected. If the pattern is present from the beginning, there is no event.

    So that means it is edge activated, and is triggered on a change-to moment ?
    That would need to be made clear in the DOCs
  • jmgjmg Posts: 14,152
    cgracey wrote: »
    There is a state-measuring smart pin mode that alternately measures high and low times, without missing a clock.

    Sounds great for Duty capture to high precision, on a single smart pin. Which mode is that ?
Sign In or Register to comment.