This simple code is giving me fits. Even the led blink sample code from this forum gives me the same errors.
Whats going on here ? This so simple it blows my mind, how I could not fix this ??
-----------The error msg on compiling ------------------------
Error: for Start value is too big for the Counter
Error: for End value is too big for the Counter
Error: Missing operand, before +
.
.
.
#chip 16F886
#option explicit
;--------------------Just for testing------------------------------------
#define testlp
'
#define DtoAClock PORTc.4 'pin 15
#define DtoADir PORTc.5 'pin 16
#define ADdata PORTb
'Set port directions
DIR DtoAClock OUT ;pin 15
DIR DtoADir OUT ;pin 16
;Set port b direction
DIR ADdata OUT ;pins 21 lsb - 28 msb
dim testlp as word
;----------------------------------------------------
do forever
wait 500 ms
For testlp = 1 to 55
set DtoAClock on ;pin 15
wait 3 ms
set DtoAClock off
wait 6 ms
Next
Loop
Last edit: Paul Haug 2017-03-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This simple code is giving me fits. Even the led blink sample code from this forum gives me the same errors.
Whats going on here ? This so simple it blows my mind, how I could not fix this ??
-----------The error msg on compiling ------------------------
Error: for Start value is too big for the Counter
Error: for End value is too big for the Counter
Error: Missing operand, before +
.
.
.
#chip 16F886
#option explicit
;--------------------Just for testing------------------------------------
#define testlp
'
#define DtoAClock PORTc.4 'pin 15
#define DtoADir PORTc.5 'pin 16
#define ADdata PORTb
'Set port directions
DIR DtoAClock OUT ;pin 15
DIR DtoADir OUT ;pin 16
;Set port b direction
DIR ADdata OUT ;pins 21 lsb - 28 msb
dim testlp as word
;----------------------------------------------------
do forever
wait 500 ms
For testlp = 1 to 55
set DtoAClock on ;pin 15
wait 3 ms
set DtoAClock off
wait 6 ms
Next
Loop
Last edit: Paul Haug 2017-03-13
Try to put 'Next testlp' and not only 'next'
You have #define testlp at the top but not defined as anything. I remove it and it compiles fine.
You cannot #define something as a constant and then later DIM it as a variable.
Remember, if the value needs to change (as in the for next loop) then do not use #define.
General Rule: #define is for constants (non-changing values)
DIM is for Variables (changing values)
Thanks guys, problem solved. William's explanation of why it didn't work is perfect Need to add that to my notes.
Paul