xylynn
Member level 2
pic16f877a icsp
Dear all
I'm newbie with PIC16F877A. I've already familiar with 16F84A.... Now I found a problem with 16F877A... First at all I try to write very simple program with it. Blinking LED. But I can't..... I connect the Vdd and MCLR with power supply 5V and Vss with ground. My program is very simple.... when I press the push buttom which connects with RB0, the LED will blink. The LED is connected with RA1...
My problem is when I switch on the power, the LED is always lighting even I didn't press the key.....I'm sure I put the push buttom between the RB0 and the 5V supply line.......
Here is my source code
porta equ 5
portb equ 6
status equ 3
trisa equ 85h
trisb equ 86h
count1 equ 0ch
count2 equ 0dh
list p=16f877a
include "p16f877a.inc"
__config h'3ff1'
errorlevel -302
org 0
goto start
start bsf status, 5
movlw 0
movwf trisa
movlw b'11111111'
movwf trisb
bcf status, 5
clrf porta
test btfss portb,0
goto test
bsf porta,1
loop bsf porta,1
call delay
call delay
call delay
bcf porta,1
call delay
call delay
call delay
goto loop
delay clrf count2
movlw 255
movwf count1
delay1 decfsz count1,1
goto delay1
decfsz count2,1
goto delay1
return
end
Dear all
I'm newbie with PIC16F877A. I've already familiar with 16F84A.... Now I found a problem with 16F877A... First at all I try to write very simple program with it. Blinking LED. But I can't..... I connect the Vdd and MCLR with power supply 5V and Vss with ground. My program is very simple.... when I press the push buttom which connects with RB0, the LED will blink. The LED is connected with RA1...
My problem is when I switch on the power, the LED is always lighting even I didn't press the key.....I'm sure I put the push buttom between the RB0 and the 5V supply line.......
Here is my source code
porta equ 5
portb equ 6
status equ 3
trisa equ 85h
trisb equ 86h
count1 equ 0ch
count2 equ 0dh
list p=16f877a
include "p16f877a.inc"
__config h'3ff1'
errorlevel -302
org 0
goto start
start bsf status, 5
movlw 0
movwf trisa
movlw b'11111111'
movwf trisb
bcf status, 5
clrf porta
test btfss portb,0
goto test
bsf porta,1
loop bsf porta,1
call delay
call delay
call delay
bcf porta,1
call delay
call delay
call delay
goto loop
delay clrf count2
movlw 255
movwf count1
delay1 decfsz count1,1
goto delay1
decfsz count2,1
goto delay1
return
end