Time variable at m1 and lower frequencies

AllyCat

Senior Member
Hi,

I've been testing a new (?) method for detecting/stretching short pulses and rather than change my test hardware to generate shorter pulses (and possibly have issues with 'scope triggering), it seemed easier to just add a SETFREQ m1 to my code. However, the program then ran extremely slowly, so I stripped the code down to the following:

Code:
#terminal 1200
#no_data
setfreq m1      ; 1 MHz clock
do
	w1 = time
	do
;  ..... 
	loop until w1 <> time     ; Fall through when the time variable increments
	sertxd(#time," ")
loop
The command data sheet doesn't say anything about the effect of reduced clock speed, but m2 does give an increment every 2 seconds, as expected. However, m1 appears to take 16 seconds, k500 gives 32 seconds and k250 64 seconds between time increments! I couldn't be bothered to try anything slower. ;)

I've tested this with an 08M2 and a 20M2. Is this a "feature" of PICaxe Basic, or have I overlooked something?

Cheers, Alan.
 

hippy

Ex-Staff (retired)
I imagine this is a feature with the incrementing being based on the 16MHz clock rather than 4MHz ...

16MHz = 1 second increment, 8MHz = 2, 4MHz = 4, 2MHz = 8, 1MHz = 16, k500 = 32, k250 = 64
 

AllyCat

Senior Member
Thanks hippy,

Yes, it struck me after posting that that's probably what has happened.

A comment on the Command Data Sheet about this "unexpected" (IMHO) feature might be helpful to others. ;)

Cheers, Alan.
 
Top