timing questions
mynet43
Posts: 644
I have two questions regarding timing. One easy and one not so...
1. Does anyone know the time it takes a propeller to start up after the power is applied? I'm sure I can look this up somewhere but it's not obvious.
2. Does anyone have assembly code that approximates the assembly waitcnt command (not the spin waitcnt)? I need this so I can be doing other stuff while it's waiting. It's tricky to do without encountering the 32 bit overflow problem. It doesn't need to be quite as precise but it should be accurate and reliable.
Thank you for your help.
Jim
1. Does anyone know the time it takes a propeller to start up after the power is applied? I'm sure I can look this up somewhere but it's not obvious.
2. Does anyone have assembly code that approximates the assembly waitcnt command (not the spin waitcnt)? I need this so I can be doing other stuff while it's waiting. It's tricky to do without encountering the 32 bit overflow problem. It doesn't need to be quite as precise but it should be accurate and reliable.
Thank you for your help.
Jim
Comments
If you search in the Parallax contests site, you should be able to find my entry which is a co-operative assembler RTOS letting one cog do more than one thing "simultaneously". There are examples as well as commented code. You should be able to get timing working to 1 usec granularity if I recall correctly without looking it up. The actual precision will be dependent on the level of "busyness" in the cog.
And as to how long a Prop takes to boot.... I think the manual states a 75-ish millisecond power-up timer.
Hope that helps.
Cheers,
Peter (pjv)
Thanks for the snippet. It looks like the trick is using the cmps, which treats it as a signed compare.
Do you have a link to your code? I'm very interested. I'm not sure where to look for the contests site.
Thanks for the info.
Jim
The real trick is the sub t1,cnt
The cmps checks only if the result of the subtract is positive (value not reached) or negative (value reached or passed).
If you subtract two 32bit numbers and the result is again a 32bit number you have no problems with overflow up to the half of the number range (31bit here). So this trick works up to ~27 seconds timing intervals @80MHz.
To 1): The booting time is ~1.6 seconds according the datasheet on page 30.
Andy
Thanks for the correction of the startup time.
I'm still having trouble understanding the waitcnt code. Sometimes I'm pretty dense
If the sub t1,cnt is determining the result, then why not use a wc on the sub command and skip the cmps command? I'm sure I'm missing something.
Thanks for your help.
Jim
You would need a sub command which returns a Sign-Flag in C. But that not exists. sub returns the overflow for unsigned numbers and subs the overflow for signed numbers.
The trick here is exactly to ignore the overflows and look just at the result if it is positive or negative.
Andy
OK, thanks, that helps.
J
I believe the link is http://www.parallax.com/Resources/ApplicationsContests/Contests/200910PropellerContest/PropRTOS/tabid/852/Default.aspx
There is a considerably more advanced RTOS that I have written, but because of the MIT requirements for publishing in the OBEX, that version remains private. If a non-MIT license publishing area existed on the Parallax site, then I would publish it there for non-commercial use.
Cheers,
Peter (pjv)
Thank you for sharing your RTOS code with me. I appreciate it.
I've looked over your code and I think I understand how to use it and how it works. I really like the compactness of your code and the way you use the jmpret command to suspend code execution and return to the scheduler.
I would be very interested in seeing your more-advanced version, to see what extensions you've added. If you're willing to share it with me, you can email it to me under separate cover.
Thanks again,
Jim