cheetha
Full Member level 2
- Joined
- Sep 17, 2011
- Messages
- 146
- Helped
- 1
- Reputation
- 2
- Reaction score
- 2
- Trophy points
- 1,298
- Activity points
- 2,310
LIST P=16F877a,r=hex,n=80,x=off,st=off
#include <P16F877.INC>
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _PWRTE_ON & _LVP_OFF
ORG 0010H
BSF STATUS, RP0
BCF STATUS, RP1
MOVLW 00H
MOVWF TRISB
MOVLW 00H
MOVWF TRISA
MOVLW 0FFH
MOVWF TRISD
BCF STATUS, RP0
BCF STATUS, RP1
CLRF 21H
CLRF 22H
CLRF 23H
MOVLW 0FFH
MOVWF PORTA
A CALL DELAY
BTFSS PORTD,0
GOTO A1
MOVLW 0FFH
MOVWF PORTB
GOTO A2
A1 CLRF PORTB
A2 CALL DELAY
GOTO A
DELAY:
MOVLW 0FFH
MOVWF 22H
AAA MOVLW 0FFH
MOVWF 21H
AA DECFSZ 21H,F
GOTO AA
DECFSZ 22H,F
GOTO AAA
RETURN
END
; progam to flash all of PortB pins on and off every 4 seconds
list p=16f877a
include p16f877a.inc
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _LVP_OFF
cblock 0x20 ; specify user regiaters
d1
d2
d3
COUNT
endc
org 0x000
GOTO Main
Main CLRF PORTB ; Set portb,c,d to digital outputs
CLRF PORTC
CLRF PORTD
BANKSEL TRISA
CLRF TRISB
CLRF TRISC
CLRF TRISD
BANKSEL 0
LOOP ; main program loo[
CALL DELAY4s
MOVLW 0xFF
MOVWF PORTB ; Set port HIGH
CALL DELAY4s
MOVLW 0x00
MOVWF PORTB ; Set port LOW
GOTO LOOP
DELAY4s ; 4 SECOND DELAY
movlw 0x23
movwf d1
movlw 0xB9
movwf d2
movlw 0x09
movwf d3
Delay_0
decfsz d1, f
goto dly1
decfsz d2, f
dly1 goto dly2
decfsz d3, f
dly2 goto Delay_0
return
END
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?