HI all,
I'm creating a little timing system that needs to be accurate to 1mS (or better).
So I started looking at Settimer & Timer3.
If my calculations are correct, a Timer3 on a 20X2 running at 64MHz with 1:1 prescale would create a minor tick every 4.096mS (giving a Major Tick count of 244.14 every second). Page 242/243 of manual 2. Obviously no good for my needs.
A SetTimer on a 20X2 running at 64MHz would create 250 minor ticks every 1mS
So
Settimer 65286 should create a Major tick after 1mS of this running.
Is that correct?
If I've done my maths right the follwing code should count in mS intervals and increment b0 every 1mS: (b1 is there to count hundredths, b2 will be added later to count tenths of a second)
Can someone cast their beady eye over this and see I'm right please?
I've ran the simulator at 20mS delay and a 100 count on b0 should be 20mS x 100 = 2secs, but I'm timing it at 20secs. A b0 count of 10 does come out at 2secs (give or take, allowing for these oldish fingers), so I'm out by a factor of 10. Is this due to the programming editor or my code?
I'm about to put a hefty order in and don't want the wrong equipment if I can't get the resolution I need.
Cheers in advance for any replies that don't call me a dumbass lol.
I'm creating a little timing system that needs to be accurate to 1mS (or better).
So I started looking at Settimer & Timer3.
If my calculations are correct, a Timer3 on a 20X2 running at 64MHz with 1:1 prescale would create a minor tick every 4.096mS (giving a Major Tick count of 244.14 every second). Page 242/243 of manual 2. Obviously no good for my needs.
A SetTimer on a 20X2 running at 64MHz would create 250 minor ticks every 1mS
So
Settimer 65286 should create a Major tick after 1mS of this running.
Is that correct?
If I've done my maths right the follwing code should count in mS intervals and increment b0 every 1mS: (b1 is there to count hundredths, b2 will be added later to count tenths of a second)
Code:
#picaxe 20x2
#no_data
#no_table
b0=0
b1=0
setfreq m64
Main:
settimer 65286
do until timer=1
inc b0
if b0=100 then
inc b1
b0=0
endif
timer=0
loop
goto main
I've ran the simulator at 20mS delay and a 100 count on b0 should be 20mS x 100 = 2secs, but I'm timing it at 20secs. A b0 count of 10 does come out at 2secs (give or take, allowing for these oldish fingers), so I'm out by a factor of 10. Is this due to the programming editor or my code?
I'm about to put a hefty order in and don't want the wrong equipment if I can't get the resolution I need.
Cheers in advance for any replies that don't call me a dumbass lol.