aljamri
Member
Hi everybody,
I am doing Nigel Goodwin's tutorials. Finished LED tutorials, and started Switches tutorial. I faced a problem and spent last week revising my work for any clear mistake. It repated itself in all the three tutorials 2.1, 2.2, and 2.3.
One of the switches and the corresponding LED turns ON whenever I switch on the power and makes no any response.
Attached Nigel's board on which I marked the Switch and LED. And this is the tutorial's link
and here is the first tutorial code where I added A into the list and config files since I am using PIC16F628A.
can any one tell me where I made mistake?
Thanks
I am doing Nigel Goodwin's tutorials. Finished LED tutorials, and started Switches tutorial. I faced a problem and spent last week revising my work for any clear mistake. It repated itself in all the three tutorials 2.1, 2.2, and 2.3.
One of the switches and the corresponding LED turns ON whenever I switch on the power and makes no any response.
Attached Nigel's board on which I marked the Switch and LED. And this is the tutorial's link
and here is the first tutorial code where I added A into the list and config files since I am using PIC16F628A.
Code:
;Tutorial 2.1 - Nigel Goodwin 2002
LIST p=16F628A ;tell assembler what chip we are using
include "P16F628A.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
LEDPORT Equ PORTA ;set constant LEDPORT = 'PORTA'
SWPORT Equ PORTA ;set constant SWPORT = 'PORTA'
LEDTRIS Equ TRISA ;set constant for TRIS register
SW1 Equ 7 ;set constants for the switches
SW2 Equ 6
SW3 Equ 5
SW4 Equ 4
LED1 Equ 3 ;and for the LED's
LED2 Equ 2
LED3 Equ 1
LED4 Equ 0
;end of defines
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'11110000' ;set PortA 4 inputs, 4 outputs
movwf LEDTRIS
bcf STATUS, RP0 ;select bank 0
clrf LEDPORT ;set all outputs low
Loop btfss SWPORT, SW1
call Switch1
btfss SWPORT, SW2
call Switch2
btfss SWPORT, SW3
call Switch3
btfss SWPORT, SW4
call Switch4
goto Loop
Switch1 clrf LEDPORT ;turn all LED's off
bsf SWPORT, LED1 ;turn LED1 on
retlw 0x00
Switch2 clrf LEDPORT ;turn all LED's off
bsf SWPORT, LED2 ;turn LED2 on
retlw 0x00
Switch3 clrf LEDPORT ;turn all LED's off
bsf SWPORT, LED3 ;turn LED3 on
retlw 0x00
Switch4 clrf LEDPORT ;turn all LED's off
bsf SWPORT, LED4 ;turn LED4 on
retlw 0x00
end
can any one tell me where I made mistake?
Thanks