falleafd
New Member
TURN MOVLW H'0F'
ANDWF XPORTB, 1 ;clear high bits of portB mirror rb4-rb7
MOVLW H'07'
ANDWF STDEX, 0 ;W as 00000sss
CALL STEPTAB ;get control vector for this index
IORWF XPORTB, 0 ;setup output for motor
MOVWF XPORTB ;update mirror and
MOVWF PORTB ;output the result!
DLYSTEP MOVLW H'00'
MOVWF TMRL
MOVLW H'C0'
MOVWF TMRH ;use 15 bit counter
LO_STEP INCFSZ TMRL ;200ns*2cycle = 400ns/1bit_counter
GOTO LO_STEP ;increase counter from D000 to ffff
NOP ;time delay = 16384*400ns = 6.5536ms
HI_STEP INCFSZ TMRH ;real time delay = 6.5536ms + 3*200 +
GOTO LO_STEP ;... it's too small.. don't care bout it.
NOP ;velocity = 1000/6.55 = 152.6 step per second
RETURN
This is the code I write to turn the motor step.
However, when I call it in another routine, it warns that TURN is not previously defined.
Error[113] D:\TURNING.ASM 113 : Symbol not previously defined (TURN)
Error[113] D:\TURNING.ASM 127 : Symbol not previously defined (TURN)
Message[302] D:\TURNING.ASM 147 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\TURNING.ASM 149 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[113] D:\TURNING.ASM 158 : Symbol not previously defined (WAITPC)
Error[113] D:\TURNING.ASM 171 : Symbol not previously defined (SET_SSR)
Error[113] D:\TURNING.ASM 172 : Symbol not previously defined (CHG)
Error[113] D:\TURNING.ASM 173 : Symbol not previously defined (TURNING)
WaitPC, set_ssr, chg and turning are also my procedure, and it warns errors..
Lines 113, 127 You may see from the code below.
ZERO CLRF PORTB
CLRF XPORTB
MOVLW H'00'
MOVWF STDEX
BTFSS SW ;check switch
GOTO CW_RST ;if off, turn the motor in clkwise
GOTO ACW_RST ;if on, turn the motor in anticlkwise
[113] CW_RST CALL TURN ;if the sw is off, turn half step
BTFSC SW ;check sw
GOTO MAIN ;done
INC_CW INCF STDEX, 1 ;increase stdex
GOTO CW_RST ;continue turn
[127]ACW_RST CALL TURN ;if the sw is on, turn half step
BTFSS SW ;check sw
GOTO INC_CW ;if off, turn in clockwise until it on
DEC_ACW DECF STDEX, 0 ;decrease stdex
GOTO ACW_RST ;continue turn
I cannot find what is the error here.
ANDWF XPORTB, 1 ;clear high bits of portB mirror rb4-rb7
MOVLW H'07'
ANDWF STDEX, 0 ;W as 00000sss
CALL STEPTAB ;get control vector for this index
IORWF XPORTB, 0 ;setup output for motor
MOVWF XPORTB ;update mirror and
MOVWF PORTB ;output the result!
DLYSTEP MOVLW H'00'
MOVWF TMRL
MOVLW H'C0'
MOVWF TMRH ;use 15 bit counter
LO_STEP INCFSZ TMRL ;200ns*2cycle = 400ns/1bit_counter
GOTO LO_STEP ;increase counter from D000 to ffff
NOP ;time delay = 16384*400ns = 6.5536ms
HI_STEP INCFSZ TMRH ;real time delay = 6.5536ms + 3*200 +
GOTO LO_STEP ;... it's too small.. don't care bout it.
NOP ;velocity = 1000/6.55 = 152.6 step per second
RETURN
This is the code I write to turn the motor step.
However, when I call it in another routine, it warns that TURN is not previously defined.
Error[113] D:\TURNING.ASM 113 : Symbol not previously defined (TURN)
Error[113] D:\TURNING.ASM 127 : Symbol not previously defined (TURN)
Message[302] D:\TURNING.ASM 147 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\TURNING.ASM 149 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[113] D:\TURNING.ASM 158 : Symbol not previously defined (WAITPC)
Error[113] D:\TURNING.ASM 171 : Symbol not previously defined (SET_SSR)
Error[113] D:\TURNING.ASM 172 : Symbol not previously defined (CHG)
Error[113] D:\TURNING.ASM 173 : Symbol not previously defined (TURNING)
WaitPC, set_ssr, chg and turning are also my procedure, and it warns errors..
Lines 113, 127 You may see from the code below.
ZERO CLRF PORTB
CLRF XPORTB
MOVLW H'00'
MOVWF STDEX
BTFSS SW ;check switch
GOTO CW_RST ;if off, turn the motor in clkwise
GOTO ACW_RST ;if on, turn the motor in anticlkwise
[113] CW_RST CALL TURN ;if the sw is off, turn half step
BTFSC SW ;check sw
GOTO MAIN ;done
INC_CW INCF STDEX, 1 ;increase stdex
GOTO CW_RST ;continue turn
[127]ACW_RST CALL TURN ;if the sw is on, turn half step
BTFSS SW ;check sw
GOTO INC_CW ;if off, turn in clockwise until it on
DEC_ACW DECF STDEX, 0 ;decrease stdex
GOTO ACW_RST ;continue turn
I cannot find what is the error here.