Thật ra chương trình của bác viết không có gì sai, chỉ thừa một vài lệnh,
dựa vào chương trình của bác tui có Edit lại chút đỉnh, và đã dùng proteus mô phỏng OK... bác thử lại xem...
Code:
;========================================
TITLE "TESTLED"
PROCESSOR PIC16f877a
INCLUDE <P16f877a.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
;=============================================================================
; KHAI BAO BIEN
;**************
_work equ 0x20
_status equ 0x21
;================================================= =====================================
ORG 0x00
Goto Main
ORG 0x04
Goto LED
Main
bsf INTCON,GIE
bsf INTCON,INTE
banksel TRISB
bsf TRISB,0
bcf TRISB,1
banksel PORTB
bcf PORTB,0
Goto $
;==========================================================
LED
movwf _work ; Save W in Bank0 or Bank1
btfsc STATUS,RP0 ; Check which bank PIC is in
goto IN_BANK0 ; IF == 0 THEN already in Bank0
; Continue here if PIC is in Bank1 on entry
bcf STATUS,RP0 ; Change into Bank0
swapf STATUS,w ; Save STATUS in Bank0
movwf _status ; in the usual way
bsf _status,RP0 ; Set back saved RP0 in memory
goto INVERT ; and begin the core code
IN_BANK0
swapf STATUS,w ; If already in Bank0
movwf _status ; save STATUS in the usual way
;============================================================
INVERT
bcf INTCON,INTF
movf PORTB,w
xorlw b'00000010'
movwf PORTB
;=============================================================
; Restore context. Processor in Bank0
swapf _status,w ; Untwist & get old Status from memory
movwf STATUS ; which also restores original bank
swapf _work,f ; Now get original W register from
swapf _work,w ; interrupted bank
retfie ; and return to interrupted background
end