Instruction Timing
gemeyer
Posts: 7
I am using a BS2P40 to control some LEDs and am getting a lot of flicker which I didn't expect with this fast processor. So I carefully timed many of the instructions that I use to turn the LED on or off ( OutBit(j) = ShadesBit(i) ) and found that it takes about .01 sec to execute that one command one time! That seems excessive.
Anybody have experience with timing instructions and making code run as fast as possible?
Thanks!
Anybody have experience with timing instructions and making code run as fast as possible?
Thanks!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
http://www.emesystems.com/BS2speed.htm
The page is mostly on the original BS2 and BS2sx timing. In general, multiply the BS2 time per command by 0.3 to estimate the time the same command would take on the BS2p.
On the BS2p, I found that a plain HIGH xpin command takes ~42 microseconds and outPin = state takes ~70 microseconds. I know the array access, like your OutBit(j) = ShadesBit(i) takes longer, but the figure you found, 10 milliseconds, seems way too much. I would have predicted less than 1 millisecond.
The Stamp is an interpreter and it has to read each token out of the serial eeprom, and that is the bottleneck. The processor in the BS2p is running at 20mhz, but the interpreted commands are executed on a time frame of 0.1 or 1 millisecond.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Also, the BS2 is a single tasking module. This means you can only do a SEROUT on one pin at a time. You can SEROUT on more than one pin, but each pin must finish its SEROUT before you can go on to the next.
Note you can turn on and off multiple LED's at a time by using the OutA, OutB, OutC, or OutD instructions.