Logic Check on Cycles Count
JonnyMac
Posts: 9,208
I have a simple PASM subroutine:
... and was just looking for a logic check on subtracting 24 from the initial ticks count to take care of call setup and return cycles. Am I on track? Now I'm thinking it should be 28 to account for DJNZ when it doesn't jump.
' --------------------- ' Pause in microseconds ' --------------------- ' pauseus mov ustimer, cnt ' sync with system clock tjz usecs, #pauseus_ret ' bail if zero sub ustimer, #24 ' account for setup/call/return add ustimer, ustix ' set timer for 1us usloop waitcnt ustimer, ustix ' wait and reload djnz usecs, #usloop ' update delay count pauseus_ret ret
... and was just looking for a logic check on subtracting 24 from the initial ticks count to take care of call setup and return cycles. Am I on track? Now I'm thinking it should be 28 to account for DJNZ when it doesn't jump.
Comments
If you want it 100% accurate you might want to use less than 4 for the mov ustimer, cnt because cnt is read in the read source cycle of an instruction ... there are greater gurus here which can tell you the right number ;o)
I think I'd just store cnt before calling the routing and then capture cnt after the call and print out the difference...
Then, just fiddle with the numbers until it comes out right...
@MagIO2: There is the call, the setup in the routine before it drops into the loop, the return. I'm going to heed Ray's advice and let the Propeller measure for me.
Thanks again for the suggestion, Ray. Test code attached for those that may be interested (I used suggested code from the Propeller Q&A site).