- schema.rar
- (81.18 KiB) Downloaded 543 times
PORT_B EQU 0x06 ; shadow copy of GPIO
;************************************************************************
org 0x0000 ; effective reset vector
;***** MAIN PROGRAM
;***** Initialisation
start
movlw b'00000000' ; configure GP2 (only) as an output
tris PORT_B
clrf PORT_B ; start with shadow GPIO zeroed
;***** Main loop
INIZIO:
bcf PORT_B,0
bsf PORT_B,0
goto INIZIO ; repeat forever
END
alieno75 wrote:Immagine_RIGOL.rar
alieno75 wrote:Per non mettere un' immagine che occupa tutto il post
list p=16F877
#include <p16F877.inc>
;***** VARIABLE DEFINITIONS
UDATA
d1 res 1 ; delay loop counters
d2 res 1
d3 res 1
d4 res 1
;************************************************************************
RESET CODE 0x0000 ; effective reset vector
;***** MAIN PROGRAM
;***** Initialisation
start
movlw b'11111000' ; configure RB0, RB1, RB2 as output, others as input
tris PORTB
bsf PORTB,0 ; RB0 = CLOCK = 1
bcf PORTB,1 ; RB1 = RESET = 0 (active LOW)
bcf PORTB,2 ; RB2 = LED = ON (active LOW)
;***** Main loop
do_reset
; do a 0.4s RESET LOW and send 1-0-1 1us clock pulses
movlw 0x36 ; initialize delay counters
movwf d1
movlw 0xE0
movwf d2
movlw 0x01
movwf d3
delay_0
bcf PORTB,0 ; CLOCK = 0
bsf PORTB,0 ; CLOCK = 1
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto delay_0
; all done, so turn off LED and RESET
bsf PORTB,2 ; LED OFF
bsf PORTB,1 ; RESET = 1
;loop forever
endless
goto endless
END
list p=16F877
#include <p16F877.inc>
;***** VARIABLE DEFINITIONS
UDATA
d1 res 1 ; delay loop counters
d2 res 1
d3 res 1
d4 res 1
;************************************************************************
RESET CODE 0x0000 ; effective reset vector
;***** MAIN PROGRAM
;***** Initialisation
start
movlw b'00000001' ; configure RB0 (PUSH BUTTON active LOW) as input, others as output
tris PORTB
banksel OPTION_REG
bcf OPTION_REG,NOT_RBPU ; enable pull-ups on PORTB inputs
banksel PORTA
movlw b'111110' ; configure RA0 (LED) as output, others as input
tris PORTA
bsf PORTB,RB1 ; RB1 = CLOCK = 1
bcf PORTB,RB2 ; RB2 = RESET = 0 (active LOW)
bcf PORTA,RA0 ; RA0 = LED = ON (active LOW)
;***** Main loop
do_reset
; do a 0.5s RESET LOW and send 1-0-1 1us clock pulses
movlw 0x36 ; initialize delay counters
movwf d1
movlw 0xE0
movwf d2
movlw 0x01
movwf d3
delay_0
bcf PORTB,RB1 ; CLOCK = 0 (make a clock 1us 1-0-1 pulse)
bsf PORTB,RB1 ; CLOCK = 1
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto delay_0
; all done, so turn off LED and RESET
bsf PORTA,RA0 ; LED OFF
bsf PORTB,RB2 ; RESET = 1
; Make a clock single pulse (0-1-0) if the PUSH BUTTON is pressed
test_pb
btfsc PORTB,RB0 ; PUSH BUTTON (RB0) pressed (active LOW)?
goto test_pb ; No (is HIGH), test it again
bcf PORTA,RA0 ; Yes (is LOW), turn LED ON
bcf PORTB,RB1 ; CLOCK = 0 (make a clock 1us 1-0-1 pulse)
bsf PORTB,RB1 ; CLOCK = 1
; 0.1s delay, than LED OFF
movlw 0x1F ; initialize delay counters (0.1s)
movwf d1
movlw 0x4F
movwf d2
Delay_1
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_1
bsf PORTA,RA0 ; LED OFF
; wait 0.4s before test PUSH BUTTON again
movlw 0x36 ; initialize delay counters (0.4s)
movwf d1
movlw 0xE0
movwf d2
movlw 0x01
movwf d3
Delay_3
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_3
goto test_pb
END
Return to Microcontrollori e microprocessori
Users browsing this forum: No registered users and 8 guests