X2 vs M2 Pause times

matchbox

Senior Member
I have run a certain program with a 14M2 for long while. And today I load it to a 28X2.
The specific part of the code that I noticed the change was a Flashing sequence, that included PAUSE's.

Its the same code with the same clock speed, M16. But the flashing sequence on the X2, is at half the speed.
Its obviously not a clock speed issue, because both serial comm lines are working fine.(RF and OLED)
I also try loading the program on two different 28X2's, with the same result.

Its a quick fix... But was wondering if this is normal? Has anyone else experienced this before?
 

Flenser

Senior Member
Matchbox,
Checkout the manual entry for PAUSE. The value you use as a parameter is calculated differently for the M2 & X2 chips:

PAUSE milliseconds
- Milliseconds is a variable/constant (0-65535) which specifies how many
milliseconds to pause (at 8MHz on X2 parts, 4MHz on all other parts)
 

matchbox

Senior Member
Thanks for the reply.
If I was running both chips at default clock frequency, for sure... But in this case both the X2 and M2 are running at 16Mhz. So I would assume that the PAUSE value would be 4x greater than the required, on both?
 

Flenser

Senior Member
matchbox,

The PICAXE firmware does not adjust the value you pass to PAUSE as a parameter when you choose a different frequency from the default. You have to do this.
e.g.
M2 @4MHz a PAUSE 100 will delay 100ms <-- at the default freq the pause parameter equals the delay in ms
M2 @8MHz a PAUSE 100 will delay 50ms
M2 @16MHz a PAUSE 100 will delay 25ms
so for an M2 if you want a 100ms pause at 16MHz you need to code PAUSE 400

The situation is similar for the X2 chips except that the default frequency that you do the calculations from is 8MHz
M2 @8MHz a PAUSE 100 will delay 100ms <-- at the default freq the pause parameter equals the delay in ms
M2 @16MHz a PAUSE 100 will delay 50ms
M2 @4MHz a PAUSE 100 will delay 200ms
so for an X2 if you want a 100ms pause at 16MHz you need to code PAUSE 200
 
Top