0% found this document useful (0 votes)
494 views3 pages

Semaforo Pic18f4550

This document contains code for a PIC microcontroller to blink LEDs in a specific pattern. It defines constants, variables, input/output pins. The main code section sets the port pins as outputs, then in a loop it writes different bit patterns to the port to light different LEDs, with delay functions in between to control the timing of the blinks.

Uploaded by

Fabian Moreno
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
494 views3 pages

Semaforo Pic18f4550

This document contains code for a PIC microcontroller to blink LEDs in a specific pattern. It defines constants, variables, input/output pins. The main code section sets the port pins as outputs, then in a loop it writes different bit patterns to the port to light different LEDs, with delay functions in between to control the timing of the blinks.

Uploaded by

Fabian Moreno
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#INCLUDE <P16F877A.

INC>

__CONFIG _HS_OSC & _WDT_OFF

#DEFINE _XTAL_FREQ 20000000 #DEFINE BANCO_1 STATUS, RP0

;-------------------;DEFINIR VARIABLES CONTA EQU CONTB EQU CONTC EQU ;-------------------ORG ;--------------------------------;DEFNIR PINES PUERTO B COMO SALIDA CLRF PORTB 0000H ;INICIO DEL PROGRAMA, POSICION DE MEMORIA 0000H 20H 21H 22H

BSF BCF

STATUS, 5 STATUS,6 CLRF BCF TRISB STATUS, RP0

;--------------------------------INICIO: MOVLW B'00000010' MOVWF PORTB

CALL RETARDO_1S CALL RETARDO_1S CALL RETARDO_1S CALL RETARDO_1S CALL RETARDO_1S MOVLW B'00000110' MOVWF PORTB CALL RETARDO_1S CALL RETARDO_1S MOVLW B'00010000' MOVWF PORTB CALL RETARDO_1S CALL RETARDO_1S CALL RETARDO_1S MOVLW B'00000100' MOVWF PORTB CALL RETARDO_1S GOTO INICIO

RETARDO_1S MOVLW .76 MOVWF CONTC RETARDO_50MS MOVLW .127 MOVWF CONTB RETARDO_200NS

MOVLW .127 MOVWF CONTA R_200NS_BUC NOP

;1 CM ;1 CM

;1 CM

DECFSZ CONTA, 1 ;1 CM, SI CONTA=0 2 CM GOTO R_200NS_BUC ;2 CM DECFSZ CONTB, 1 GOTO RETARDO_200NS DECFSZ CONTC, 1 GOTO RETARDO_50MS RETURN ;2 CM

END

You might also like