Error: Loop without do

Gramps

Senior Member
What causes this error??

loop:
^
Syntax error on line 13 at/before position 4

Error: Loop without Do
Code:
#picaxe 18m2 ; type chip used

;setfreq m4 ; All M2 parts internal k31,
; k250, k500, m1, m2, m4, m8,m16,m32

symbol control = C.1
symbol val = w0 ; word (16-bit) user variable
symbol pwmPin = B.3 ; use only B.3 or B.6

init: ; setup PWM
pwmout pwmdiv4, pwmPin, 124, 1023

loop:
; readadc returns 8 MSB if used
readadc10 control, val ; get 10-bit value
; read 10-bit ADC into variable w0

pwmduty pwmPin, val ; set pwm duty
goto loop ; loop back to start


Thanks, Gramps

code captured from bristolwatch.com
 
Last edited:

Buzby

Senior Member
'Loop' is a reserved word, and it needs a corresponding 'Do' to work.

Simplest solution is rename the two occurences of 'Loop' to 'Myloop',

Or replace the first with 'Do', and change delete 'goto' to make just 'Loop'.

See page 62 in Manual 2 for explanation of 'Do .. Loop'.

Also, the website is bristolwatch.com, not bristolwathch.

( The website author says every project has been built and tested, which project is this code from ? )

Cheers,

Buzby
 
Last edited:
Top