Processing speed

crazynight

Senior Member
How fast are lines of code processed? I know the 20m2 runs at 32MHz but when multi tasking it runs at 4Mhz. but how quickly would it suspend task 2 and restart task 4.

Code:
high G1		;green on
suspend 2	;suspend task2 red start fault monitor as no longer needed
SUSPEND 6
	i2cslave slvAddrWR, i2cslow, i2cbyte		;Initialize RTC
	writei2c 2,(%00000000)					;reset minutes
	writei2c 1,(%00000000)					;reset seconds
	writei2c 3,(%00000000)					;reset milliseconds
restart 4
restart 7
 

nick12ab

Senior Member
When multitasking the PICAXE runs at 4MHz after the clock divider is taken into consideration, or 16MHz before.

Unlike a normal PIC microcontroller or Arduino, PICAXE BASIC is interpreted so it is much slower than those. Rev-Ed say that it should execute 16000 commands per seconds (at that speed).
 

hippy

Technical Support
Staff member
There is no definitive answer for this one, more so than for other execution speed related questions.

Between commands in one task, one or more other tasks will execute commands, and it would depend on how long those commands took.

If one assumes the usually adopted rule of thumb that it's about 250us per simple command at 4MHz, 125us per 'token' of executable code, ignoring the above issue, adjusting for 16MHz, then it's possibly about 650us.

Added: Actually more, because I haven't considered how long the actual I2C transactions would take.

The best thing would be to TOGGLE an I/O on at the start, off at the end, measure those pulses, determine the min, max and other values.
 
Top