The code works somewhat. Meaning the Drum motor is reversed as the Dsw is pressed. The output toggles perfectly but the Gsw is not working at all. I really do not know why this should happen, since GSw is same as DSw.;******************************************************************************
; *
; Filename: Coil Winder Control.asm *
; Date: 1 Sep 2010 *
; File Version: V1.0 *
; *
; Author: Rifaa-ath Razei *
; Company: *
; *
; *
;******************************************************************************
;------------------------------------------------------------------------------
; PROCESSOR DECLARATION
;------------------------------------------------------------------------------
LIST P=12F629 ; list directive to define processor
#INCLUDE <P12F629.INC> ; processor specific variable definitions
;------------------------------------------------------------------------------
; GP0 - output control to Drum Direction Ctrl
; GP1 - output control to Guide Direction Ctrl
; GP2 - Tacho Intput, interrupt on change enabled
; GP3 - Drum Dir ctrl switch In
; GP4 - Guide Dir ctrl switch In
; GP5 - Guide Drive Pulse Out
;------------------------------------------------------------------------------
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;------------------------------------------------------------------------------
; VARIABLE DEFINITIONS
;------------------------------------------------------------------------------
INT_VAR UDATA_SHR 0x20
d1 RES 1
d2 RES 1
;------------------------------------------------------------------------------
DATAEE CODE 0x2100
DE "Coil Winder Control"
DE "V 1.0"
DE "Vialogic Pvt Ltd"
#define Bank0 BCF STATUS,RP0
#define Bank1 BSF STATUS,RP0
#define GD GPIO,5 ; Guide Motor drive pulse out
#define DSw GPIO,4 ; Drum Motor reverse switch
#define GSw GPIO,3 ; Guide Motor reverse switch
#define DDr GPIO,0 ; Drum drive ctrl
#define GDr GPIO,1 ; Guide drive ctrl
#define Tach GPIO,2 ; Tacho Input
;------------------------------------------------------------------------------
; RESET VECTOR
RESET_VECTOR ORG 0x0000 ; processor reset vector
GOTO MAIN ; go to beginning of program
; INTERRUPT VECTOR
INT_VECTOR
ORG 0x0004 ; interrupt vector location
; MOVWF W_TEMP ; save off current W register contents
; MOVF STATUS,w ; move status register into W register
; MOVWF STATUS_TEMP ; save off contents of STATUS register
; ISR
; MOVF STATUS_TEMP,w ; retrieve copy of STATUS register
; MOVWF STATUS ; restore pre-isr STATUS register contents
; SWAPF W_TEMP,f
; SWAPF W_TEMP,w ; restore pre-isr W register contents
; RETFIE ; return from interrupt
;Oscillator Caliberation
errorlevel -302
Bank1 ; set file register bank to 1
call 0x3FF ; retrieve factory calibration value
movwf OSCCAL ; update register with factory cal value
Bank0 ; set file register bank to 0
errorlevel +302
;-------------------------------------------------------------------------------
; MAIN ROUTINE
MAIN
clrf GPIO ; Clear Outputs
movlw 07h ; Disable-
movwf CMCON ; comparator
Bank1
movlw b'011100' ; IO Pin Dir
movwf TRISIO
Bank0
movfw b'000000' ; Load Value to Clear all outputs
movwf GPIO ; Send to port
; Reading switches
SWtest
btfss DSw ; Tests for Sw press
goto DSwOn ; If pressed, goto toggle Drum drive
btfss GSw ; Tests for Sw press
goto GSwOn ; If pressed, goto toggle Guide drive
goto SWtest ; If no action, ontinue scanning
DSwOn
call Debounce ; Sw debouncing
btfss DSw ; Test for Sw release
goto DSwOn
movf DDr ; Read Drum drive value to W reg
xorlw b'000001' ; toggle Drum drive
movwf GPIO ; Write to port
goto SWtest ; Back to Sw scanning
GSwOn
call Debounce ; Sw debouncing
btfss GSw ; Test for Sw release
goto GSwOn
movf GDr ; Read Guide drive value to W reg
xorlw b'000010' ; toggle Guide drive
movwf GPIO ; Write to port
goto SWtest ; Back to Sw scanning
Debounce
;1993 cycles ; Sw deboune delay is set to 2ms @ 4MHz
movlw 0x8E
movwf d1
movlw 0x02
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
END
ThanksHello R!f@@,
Congratulations with the result.
That looks professional.
Could you already try them out on how they sound now?
Bertus