Looking for a second set of eyes
turbosupra
Posts: 1,088
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.
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
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.
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?