We got question on Duinomite support forum if small delays of 10 uS could be implemented with Duinomite Basic (DM-BASIC).
Duinomite Basic is interpreted language and it’s relatively slow, I write relatively as for some applications it’s still fast but for other slow. So I was interested how much time DM-BASIC needs to execute one BASIC instruction.
It was easy to implement as DM-BASIC have TIMER which increments every 1 mS, so I wrote this code:
10 TIMER = 0 ‘ clear the TIMER
20 I = I + 1 ‘ do one basic command like adding 1 to I variable
30 IF TIMER < 1000 THEN 20 ‘and execute this command until 1 second pass
40 PRINT “Speed approx.: “;I*3;” BIPS” ‘ print the result
Speed approx.: 31044 BIPS
BIPS = BASIC instructions per second
In the result we multiply I * 3 as the IF statement is composed by two instructions – the IF and the GOTO which forward the code to line 20
so the one simple BASIC instruction in DM-BASIC takes approximately 32 uS.
32 uS is slow for some processes, but if you want to do something fast you can always include it in the firmware as it’s open source and available for users to modify. this way was added support for the iButtons they require uS timing for communication and was impossible to do this in BASIC, so Gerard Sexton wrote additional BASIC commands which to communicate with MAXIM-DALLAS iBUTTONs.