Hello everyone, I am on the start of learning about PICs, I have found Nigel Goodwin web site and have found project for turning one LED on and in that time turn all other LED off.Program was made for PIC 16F628 and I tried to modifed it for PIC16F628A and it does not work. Here is the code, can someone tell me what is wrong.All LEDs are ON all the time,
;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 _INTOSC_OSC_CLKOUT
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 LEDPORT
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
thanks
Bookmarks