Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ask for help (assembly code)

Status
Not open for further replies.

fengshao

New Member
Code:
;************************************************************************************
; SingleStep - Single Step the motor
;
;************************************************************************************
SingleStep
	movlw	8
	movwf	StepModeScaler
	incf	State,f			; Increment motor state
	movlw	0xFF			; Turn off PWMs	 
	movwf	CCPR1L
	movwf	CCPR2L
	movlw	0x30
	iorwf	CCP1CON,f
	iorwf	CCP1CON,f
SingleStateMachine			; jump to motor state based on State pointer
	movlw	high SingleJumpTable
	movwf	PCLATH
	movf	State,w
	andlw	0x03
	addlw	low SingleJumpTable
	btfsc	STATUS,C	
	incf	PCLATH,f
	movwf	PCL
	
SingleJumpTable
	goto	SingleState0
	goto	SingleState1
	goto	SingleState2
	goto	SingleState3

SingleState0
	movlw	CTRL1FWD
	movwf	PORTD
	goto	Main

SingleState1
	movlw	CTRL2REV
	movwf	PORTD
	goto	Main

SingleState2
	movlw	CTRL1REV
	movwf	PORTD
	goto	Main

SingleState3
	movlw	CTRL2FWD
	movwf	PORTD
	goto	Main

--------------------------------------------------

Can anyone explain to me how does it to make stepper motor step???????????????????????
thankyou very much
 
Last edited:
Have a look at this and other similar AppNotes from Microchip - they should help you understand the code.

https://www.electro-tech-online.com/custompdfs/2009/05/00907a-1.pdf

hi friend i read AN907 ,i just roughly know about how to make stepper run .but after i come to code part ,how is it go ,i dont understand
Code:
SingleStep
	movlw	8
	movwf	StepModeScaler
	incf	State,f			; Increment motor state
	movlw	0xFF			; Turn off PWMs	 
	movwf	CCPR1L
	movwf	CCPR2L
	movlw	0x30
	iorwf	CCP1CON,f
	iorwf	CCP1CON,f
SingleStateMachine			; jump to motor state based on State pointer
	movlw	high SingleJumpTable
	movwf	PCLATH
	movf	State,w
	andlw	0x03
	addlw	low SingleJumpTable
	btfsc	STATUS,C	
	incf	PCLATH,f
	movwf	PCL
	
SingleJumpTable
	goto	SingleState0
	goto	SingleState1
	goto	SingleState2
	goto	SingleState3

SingleState0
	movlw	CTRL1FWD
	movwf	PORTD
	goto	Main

SingleState1
	movlw	CTRL2REV
	movwf	PORTD
	goto	Main

SingleState2
	movlw	CTRL1REV
	movwf	PORTD
	goto	Main

SingleState3
	movlw	CTRL2FWD
	movwf	PORTD
	goto	Main
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top