Code: Select all
Stepper.bas:20: Internal Error: attempt to use address of "Delay_Timer" before assignment
Stepper.bas:60: Internal Error: attempt to use address of "Counter" before assignment
The code is as follows
Code: Select all
Option Explicit
Option TargetCPU ZX24ae
Option Base 0
'Public Const LCDOutputPin as Byte = 5
'Public Const LCDInputPin as Byte = 0
'Public Const LCDPort as Byte = 3
Public Const StepperA as Byte = 28 'PB0
Public Const StepperA_Bar as Byte = 27 'PB1
Public Const StepperB as Byte = 26 'PB2
Public Const StepperB_Bar as Byte = 25 'PB3
Public Const Clear_Pins as Byte = &b0000_1111
Public Half_Steps(8) as Byte
Public Delay_Timer as Integer = 220 'ticks
' FDK Stepper:
' A = Blue
' A_Bar = Yellow
' B = Red
' B_Bar = White
Sub Main()
'initialize variables
Half_Steps(0) = &B1010_0000
Half_Steps(1) = &B1000_0000
Half_Steps(2) = &B1001_0000
Half_Steps(3) = &B0001_0000
Half_Steps(4) = &B0101_0000
Half_Steps(5) = &B0100_0000
Half_Steps(6) = &B0110_0000
Half_Steps(7) = &B0010_0000
' initialize I/O pins
Call PutPin (B.0, zxOutputLow)
Call PutPin (B.1, zxOutputLow)
Call PutPin (B.2, zxOutputLow)
Call PutPin (B.3, zxOutputLow)
'test loop
do
call PutPin(28, zxOutPutHigh)
Call Sleep(255)
Call PutPin(28, zxOutPutLow)
Call Sleep(255)
loop
Dim Counter as Byte = 0
Do
'Clear the pins
Register.PortB = Register.PortB AND Clear_Pins
'Set the pins to the new state
Register.PortB = Register.PortB OR Half_Steps(Counter)
'increment the state
Counter = Counter +1
if (Counter = 8) then
counter = 0
end if
'delay for a moment
Call Sleep(Delay_Timer)
Delay_Timer = Delay_Timer -10
if (Delay_Timer <=20) then
Delay_timer = 220
End If
Loop
End Sub
I would have thought I would get a warning about an unused variable, but not an internal error.
-Tony