Hi Mark;
Yes, I feel quite stupid - I've been through the Language Reference several times per day for a couple of weeks, and I never noticed the Waitus statement. Live and learn. I've taken some time this morning to work with Waitus, and here's what I've found.
With an 8MHz clock, and using Bascom's software simulator, it appears the Waitus statement has an overhead of 1.875uS, and each increment of the variable adds 0.5uS to the delay. Here's some measurements:
X -- Delay
- -- ------
0 -- 1.875
1 -- 2.375
2 -- 2.875
3 -- 3.375
4 -- 3.875
5 -- 4.375
:
20 -- 11.875
Here's the code I used
-------------------------------
$regfile = "Attiny2313a.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 10
$framesize = 40
Config Portb = Output
Dim A As Byte
Dim X As Byte
A = 0
X = 20
A = 0
Waitus X
A = 1
End
-----------------------------
The method I've been using to measure execution times has been to place the cursor on the Waitus X line, and click "Run to current line." I note the cycle time, move the cursor to the executable line directly below, and click the same button again. I then subtract the two time values. I suspect it's working properly, because of the results. I can actually live quite nicely with Waitus the way it is.
One related question has to do with the delay plus the time setting the port. I've measured "Set Portb.0" (or reset) as requiring 5 clock cycles, or 0.625uS to complete. Does it take that long for the port to transition, or are any of those clock cycles added after the pin is physically changed? When I receive my hardware and build my programmer I can look at it on the scope, but it would be nice to know what to expect.
Thanks again for pointing out the obvious waitus and not laughing!
Best Regards, Ken
↧