Shop OBEX P1 Docs P2 Docs Learn Events
Setting a timeout for WAITATN - can't get it to work — Parallax Forums

Setting a timeout for WAITATN - can't get it to work

bob_g4bbybob_g4bby Posts: 401
edited 2021-05-10 20:28 in Propeller 2

In assembler, using WAITATN by itself works fine - but I don't like using it because it will wait forever if ATN isn't set.

This code doesn't work for me, though, for WAITATN with a timeout

getct xx                           ' read the bottom half of the 64 bit system counter
add a,xx                         ' add in the required timeout in ticks
setq a                             ' timeout set for when the system counter = a
waitatn wc                     ' wait for atn flag then clear it and reset carry, else set carry if no ATN happens

The loop this is part of no longer loops when I set ATN for the cog it's running in. What am I doing wrong? (If this code appears a bit weird, it's because it's the assembler in Taqoz)

Has anyone got WAITATN with a timeout to work, please? If so, please show me your equivalent code fragment

Thanks, Bob

Comments

  • cgraceycgracey Posts: 14,133

    Maybe you are corrupting 'a'. How about this, instead:

      getct   xx
      add     xx,a
      setq    xx
      waitatn wc
    
  • Chip, thanks for the suggestion, that wasn't it. I got it to go perfectly, and my WAITATN word in TAQOZ looks like this:-

    --- The cog waits for the ATN flag for up to 'clocks' ticks. 
    --- If ATN occurs before timeout, 'flag' = 1, else if timedout, 'flag' = 0
    code WAITATN                ( clocks -- flag ) 
            getct xx            ' read the bottom half of the 64 bit system counter
            add a,xx
            setq a              ' timeout set for when the system counter = a
            waitatn wc          ' wait for atn flag
    if_nc   mov a,#1        ' ATN flag detected
    if_c        mov a,#0        ' we timed out
            ret
    end
    

    I'll post a complete demo on one of the TAQOZ threads

  • cgraceycgracey Posts: 14,133
    edited 2021-05-11 14:10

    Bob, there is an instruction which gets C or !C into a register. You can replace the last three lines with:

      _RET_  WRNC    a
    
  • bob_g4bbybob_g4bby Posts: 401
    edited 2021-05-11 15:50

    Thanks Chip, the instruction set is unfamiliar just yet. That fft you did a while back was compact. I hope to adapt it to process an IQ signal stream for software radio, with other dsp blocks in assembly, glued together with Taqoz. I have a feeling that WAITATN will come in very handy, syncing the cogs that do the signal processing. There's plenty of scope for parallelism.

Sign In or Register to comment.