Question re 20M2 Time Variable

I've been playing around with the 20M2 Time variable, and I'm getting some strange results. In Section 2 of the PICAXE Manual (enabletime and disabletime docs) it states that the time variable will increment at speed multiples at 8MHz and 16MHz, i.e., twice as fast (compared to 4MHZ) at 8MHz and four times as fast at 32MHz. However, at 8MHz I find that it increments twice as SLOWLY (i.e., every 2 seconds), and at 32MHz it increments only twice as fast (every 0.5 seconds), not four times as fast.

Code:
setfreq M8
time = 0
  
do
   w0 = time + 1
  sertxd (#time,cr,lf)
  tarry: if w0 > time then tarry
loop
So, I'm hoping the Manual is in error, yes?
 
Last edited:

nick12ab

Senior Member
I find the same on the 18M2 - using the timer at 16MHz gets the timer to run at 1s. Which version are you looking at? The latest one says
The time function will work correctly at 4MHz or 16 MHz. At other clock speeds it will function at the speed multiple (ie at 8MHz it will increment every 0.5s).
which appears to be correct.

The latest one is v7.8.10. It is also correct in 7.7.05 from May 2011.
 
I'm using PE version 5.5.0, and 0.5s is what it says in the most recent version of the manual, but with the 20M2, I'm getting 2.0s increments in time. The processor is running twice as fast (compared to 4MHz), but time is incrementing twice as slowly - that's what has me confused!
 

Technical

Technical Support
Staff member
Yes, the documentation could be clearer.

The time function is designed to work correctly at 4 and 16MHz, and so basically time only has two settings, regardless of the actual speed in use.

At 2 or 4 it will use the 4MHz setting.
At 8, 16, or 32 it will use the 16MHz setting.

So at 8 it is using the 16MHz setting, but the clock is running half the speed actually expected. Hence the 2s tick.
At 32 it is still using the 16MHz setting, but the clock is running twice the speed actually expected. Hence the 0.5s tick.
 
Sorry, I thought you meant what version of the Programming Editor. Version 7.8 of Section 2 of the Manual is what I'm using. As Technical clarified in post #4, the documentation in v7.8 needs clarification.
 
Top