用PIC的RA1,RB6,RB4 和RA0 配合输出使步进电机转动,
但搞不清怎样用软件控制这几个口才能正常驱动?
另外,还不知道什么情况下LM393的通道1输出口输出低电平到PIC的/MCLR 脚产生复位?
恳请单片机大侠们发表意见.
下面是在WAVE3.2下的PIC汇编程序,但仿真不出效果,请大家指正.
org 00h
Start:
call test
nop
movlw 0
MOVwF FSR
tris PORTA ;设为输出。
NOP
movlw 0
tris PORTB ;设为输出。
NOP
movlw 0FFh ;初始化A ,B 口。
movwf PORTA
NOP
movwf PORTB
NOP
call DELAY1 ;延时2MS。
bcf PORTA,0 ;0 ;RA0 输出低。
NOP
Loop:
bcf PORTA,1 ;011
NOP
bsf PORTB,6 ;
NOP
bsf PORTB,4 ;
NOP
call DELAY
bcf PORTA,1 ;001
NOP
bcf PORTB,6 ;
NOP
bsf PORTB,4 ;
NOP
call DELAY
bsf PORTA,1 ;101
NOP
bcf PORTB,6 ;
NOP
bsf PORTB,4 ;
NOP
call DELAY
bsf PORTA,1 ;100
NOP
bcf PORTB,6 ;
NOP
bcf PORTB,4 ;
NOP
call DELAY
bsf PORTA,1 ;110
NOP
bsf PORTB,6 ;
NOP
bcf PORTB,4 ;
NOP
call DELAY
bcf PORTA,1 ;010
NOP
bsf PORTB,6 ;
NOP
bcf PORTB,4 ;
NOP
call DELAY
goto Loop
DELAY: movlw 00h
movwf 10h
movlw 02h
movwf 11h
DELA: nop
decfsz 10h
goto DELA
decfsz 11h
goto DELA
retlw 0
DELAY1: movlw 80h
movwf 10h
DELA1: nop
decfsz 10h
goto DELA1
retlw 0
DLY: movlw 00h
movwf 11h
DL: movlw 00h
movwf 10h
DY: decfsz 10h
goto DY
decfsz 11h
goto DL
retlw 0
test: movlw 18h
movwf 12h
movlw 00h
movwf 11h
movlw 00h
movwf 10h
testa: nop
decfsz 10h
goto testa
decfsz 11h
goto testa
decfsz 12h
goto testa
retlw 0
org 1ffh ;RESET VECTION.
goto Start
end