Shop Learn P1 Docs P2 Docs
PASM headscratcher with user defined counter — Parallax Forums

PASM headscratcher with user defined counter

ke4pjwke4pjw Posts: 672
edited 2022-07-07 19:59 in PASM2/Spin2 (P2)

So I am modifying my E1.31 receiver code in the W6100 driver to add counters for received packets and discards. I have a real head scratcher with what is happening here. This section of code is where the E1.31 configuration structure is scanned for a matching universe. This structure is located in the LUT. When a value of zero is pulled from the LUT, that indicates that the entire structure was scanned and no matching E1.31 universe was found. That functions correctly. However, when the conditional ADD occurs, I would have expected the value of lE131Discards to start incrementing starting from the initial 0, but it increments to a very large number. At most it should increment by 25 every one second in my test scenario. Am I doing something stupid here and not realizing it?

e131lutenum
      RDLUT tE131ENUM, E131ENUM  wz ' Read the E1.31 Universe in the config
if_z  ADD lE131Discards, 1    ' Increment E131 discard counter
debug(uhex(lE131Discards))
if_z  jmp #lskipit ' End of the config. Skip decoding this packet.
      CMP tE131ENUM, tE131ADDR wz ' Compare the received E1.31 Universe with the one in the config.
if_nz ADD E131ENUM, #4 ' Increment to the next E1.31 Universe in the config
if_nz jmp #e131lutenum ' Go fish again to find a match
      ADD E131ENUM, #1 
      RDLUT tpixlen,E131ENUM
      ADD E131ENUM, #1
      RDLUT lrxptr, E131ENUM
      REP     #1, #3
      ADD  pixlen, tpixlen

PS: Tried with both ADD lE131Discards, 1 and ADD lE131Discards, #1

Comments

  • AribaAriba Posts: 2,590

    It has to be ADD lE131Discards, #1 for incrementing by one. Without the # you add the content of register 1 (which may be this large number you see).

    Andy

  • @Ariba said:
    It has to be ADD lE131Discards, #1 for incrementing by one. Without the # you add the content of register 1 (which may be this large number you see).

    Andy

    That's what I did first time around and then got confused trying to understand what is happening. Spent several hours on it last night. This should have been straight-forward. I am going to simplify it to see what I may be doing wrong.

  • I figured it out. You must initialize the register with a mov lE131Discards, #0

    Like all painful lessons like this, I know I'm not going to do that again. :wink:

Sign In or Register to comment.