Speed Question - very slow

Revolvr

New Member
I created a speed test program that acts as a crude SW PWM running on the 18X. I had expected this to run so fast I couldn't see the LED blinking.

However this program is running at about 10 cycles per second. I had played with the debugger earlier and thought perhaps it was still on, but I have not figured out why it is running so slowly.

The program is below. The LED attached to output 2 blinks at about 10 Hz. I had expected it to fade on then reset to off and cycle again. Is this the speed I should expect or have I configured something wrong?

The PWM period is 256 cycles thru main.

Thanks,
-- Dan


symbol mark = b0
symbol i = b1
symbol space = b2

main:

inc mark

space = 255 - mark

high 2
for i = 0 to mark
next i

low 2
for i = 0 to space
next i

goto main
 

hippy

Ex-Staff (retired)
PICAXE execution times are in the rough order of about 250uS so a FOR-NEXT loop takes 500uS per count, so 250 counts is around 125mS, about a 1/10th of a second, worst case.

Using SERFREQ M8 will double execution speeds.

An alternative, untested so no idea of if it's any better could be ...<code><pre><font size=2 face='Courier'>Do
Inc mark
i = 0
Do
If i &lt;= mark Then
High 2
Else
Low 2
End if
Inc i
Loop Until i = 0
Loop </font></pre></code>
 
Top