Shop OBEX P1 Docs P2 Docs Learn Events
Looking for a second set of eyes — Parallax Forums

Looking for a second set of eyes

turbosupraturbosupra Posts: 1,088
edited 2012-05-28 14:14 in Propeller 1
I'm chasing a timing issue right now (I think) and does my code break here if timeStampCamAdjust

add timeStampCamAdjust, fiftiethClk

when timeStampCamAdjust is negative? If so, what's a good way to handle that?

Its purpose is to act similar to a waitcnt but not stop the cog, so unless cnt - timeStampCamAdjust > 0, it skips to the next method and bypasses this one until cnt - timeStampCamAdjust is greater than 0.



                        mov     cntT, cnt
                        sub     cntT, timeStampCamAdjust
                        
                        cmps    cntT, #0 WC, WZ
if_b                    jmp     #readSolenoidPulseWidth
 

                      
                        cmp     correctionFactor, adjustmentCeiling WC, WZ
if_a                    mov     correctionFactor, adjustmentCeiling                        
                        
                       
                        cmp     highCycles, oneHunFiftyThou WC, WZ                       
if_a                    sub     correctionFactor, crankCyclesDegOfRot
if_a                    add     timeStampCamAdjust, fiftiethClk'twentyFifthClk'hundrethClk'quarterClk'tenthClk
     
                                                

                        cmp     lowCycles, oneHunFiftyThou WC, WZ
if_a                    add     correctionFactor, crankCyclesDegOfRot
if_a                    add     timeStampCamAdjust, fiftiethClk'twentyFifthClk'hundrethClk'quarterClk'tenthClk                                                


Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-28 09:14
    For checking whether the sign bit is set, I'll often use:
                                  shl     cntT, #1   nr,wc
              if_c                jmp    #readSolenoidPulseWidth
    
    For setting an upper bound on something, I'll use:
                                   max    correctionFactor, adjustmentCeiling
    
    You have to read the MAX / MIN instruction definitions carefully. The names are the opposite of what you might expect in some circumstances.

    Did you want IF_A on the last few instructions or did you want IF_B? IF_B may keep lowCycles at or above oneHunFiftyThou or maybe I don't understand what you're trying to do there.
  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-28 14:14
    Hi Mike,

    Thanks for replying. I believe my code is self defeating when the values are negative but I'm not sure, I'm taking a cnt timestamp value and adding to it under certain conditions and subtracting from it in other conditions.

    The point of the code is to either extend or reduce a time buffer. My concern is that I might be reducing the time buffer (when I'm trying to extend it) when the timestamp value is negative. If the value is negative and I add cycles to it in an attempt to extend the number of cycles in the timestamp buffer, does it indeed extend it or reduce it?

    In one comparison if high cycles is > 150k I want to subtract (reduce) the timestamp buffer, on the other hand if lowcycles is > 150k, I want to extend the timestamp buffer. Does that make sense?
Sign In or Register to comment.