0% found this document useful (0 votes)
57 views25 pages

Reportes Zarate

This document describes a practice using a PIC18F4550 microprocessor to learn how to use a push button. The objective is to learn to use an interrupt switch through an assembly language program for the PIC18F4550 for a specific function. The document includes configuration bits for the microprocessor and discusses using an interrupt service routine to detect when the button is pressed.

Uploaded by

Aldair Lozano
Copyright
© © All Rights Reserved
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)
57 views25 pages

Reportes Zarate

This document describes a practice using a PIC18F4550 microprocessor to learn how to use a push button. The objective is to learn to use an interrupt switch through an assembly language program for the PIC18F4550 for a specific function. The document includes configuration bits for the microprocessor and discusses using an interrupt service routine to detect when the button is pressed.

Uploaded by

Aldair Lozano
Copyright
© © All Rights Reserved
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/ 25

INSTITUTO POLITÉCNICO NACIONAL

ESCUELA SUPERIOR DE INGENIERÍA MECÁNICA Y ELÉCTRICA


UNIDAD ZACATENCO
INGENIERÍA EN COMUNICACIONES Y ELÉCTRONICA

Microprocesadores.
Práctica: Práctica LCD

PROFESOR:
VÁZQUEZ ZARATE AGUSTÍN.

Grupo: 6CV5

Integrantes:
Objetivo:

Aprender a utilizar el display 16x2 en el pic 18F4550

Desarrollo:

;******************************************************************************

; This file is a basic template for assembly code for a PIC18F4550. Copy

; this file into your project directory and modify or add to it as needed. *

; The PIC18FXXXX architecture allows two interrupt configurations. This

; template code is written for priority interrupt levels and the IPEN bit

; in the RCON register must be set to enable priority levels. If IPEN is

; left in its default zero state, only the interrupt vector at 0x008 will

; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not

; be needed.

; Refer to the MPASM User's Guide for additional information on the

; features of the assembler.

; Refer to the PIC18FXX50/XX55 Data Sheet for additional

; information on the architecture and instruction set.

;******************************************************************************

; Filename: PlantillaASM *

; Date: 12/01/11 *

; File Version: 1.0 *

; *

; Author: Ing. Alejandro Vicente Lugo Silva *

; Company: Acad. Computación ICE - ESIME Zac. *


; *

;******************************************************************************

; *

; Files required: P18F4550.INC *

; *

;******************************************************************************

LIST P=18F4550, F=INHX32 ;directive to define processor

#include <P18F4550.INC> ;processor specific variable definitions

;******************************************************************************

;Configuration bits

CONFIG PLLDIV = 5 ;(20 MHz crystal on PICDEM FS USB board)

CONFIG CPUDIV = OSC1_PLL2

CONFIG USBDIV = 2 ;Clock source from 96MHz PLL/2

CONFIG FOSC = HSPLL_HS

CONFIG FCMEN = OFF

CONFIG IESO = OFF

CONFIG PWRT = OFF

CONFIG BOR = ON

CONFIG BORV =3

CONFIG VREGEN = ON ;USB Voltage Regulator

config WDT = OFF

config WDTPS = 32768

config MCLRE = ON

config LPT1OSC = OFF

config PBADEN = OFF ;NOTE: modifying this value here won't have an effect
;on the application. See the top of the
main() function.

;By default the RB4 I/O pin is used to


detect if the

;firmware should enter the bootloader or


the main application

;firmware after a reset. In order to do


this, it needs to

;configure RB4 as a digital input, thereby


changing it from

;the reset value according to this


configuration bit.

config CCP2MX = ON

config STVREN = ON

config LVP = OFF

config ICPRT = OFF ; Dedicated In-Circuit Debug/Programming

config XINST = OFF ; Extended Instruction Set

config CP0 = OFF

config CP1 = OFF

config CP2 = OFF

config CP3 = OFF

config CPB = OFF

config CPD = OFF

config WRT0 = OFF

config WRT1 = OFF

config WRT2 = OFF

config WRT3 = OFF

config WRTB = OFF ; Boot Block Write Protection

config WRTC = OFF

config WRTD = OFF

config EBTR0 = OFF


config EBTR1 = OFF

config EBTR2 = OFF

config EBTR3 = OFF

config EBTRB = OFF

;******************************************************************************

;Variable definitions

; These variables are only needed if low priority interrupts are used.

; More variables may be needed to store other special function registers used

; in the interrupt routines.

;******************************************************************************

;Reset vector

; This code will start executing when a reset occurs.

RESET_VECTOR ORG 0

goto Main ;go to start of main code

;******************************************************************************

;******************************************************************************

;Start of main program

; The main program code is placed here.

ORG 0x1000

CALL CONFIGPUERTOS
Main ; *** main code goes here **

CALL Inicializa_LCD ;inicializamos lcd

MOVLW CLEAR ;INSTRUCCION PARA LLEGAR AL LCD

MOVWF DATO ;MOVEMOS AL PARAMETRO DATO

CALL Comando_LCD

MOVLW DDRAM_L1 ; INSTRUCCION PARA MOVERSE A LA LINEA 1

ADDLW .6 ;SUMAMOS 6 PARA DESPLAZARNOS 6 CARACTERES Y CENTRAR EL


TEXTO

MOVWF DATO ;MOVEMOS AL PARAMETRO DATO

CALL Comando_LCD

MOVLW 'H'

MOVWF DATO

CALL Dato_LCD

MOVLW 'O'

MOVWF DATO

CALL Dato_LCD

MOVLW 'L'

MOVWF DATO

CALL Dato_LCD

MOVLW 'A'

MOVWF DATO

CALL Dato_LCD

CLRF PORTD ;LIMPIAMOS PUERTO D

GOTO Main
; end of main

;******************************************************************************

; Start of subrutines

CONFIGPUERTOS

CLRF WREG

MOVLW H'0F'

MOVWF ADCON1

CLRF TRISD

CLRF PORTD

#include <H:\lcd.INC>

;******************************************************************************

;******************************************************************************

;End of program

END
Diagrama del circuito:

Conclusiones:
INSTITUTO POLITÉCNICO NACIONAL
ESCUELA SUPERIOR DE INGENIERÍA MECÁNICA Y ELÉCTRICA
UNIDAD ZACATENCO
INGENIERÍA EN COMUNICACIONES Y ELÉCTRONICA

Microprocesadores.
Práctica: Push Botton

Profesor:
Vázquez Zarate Agustín.

Grupo: 6CV5

Integrantes

Objetivo:
Aprender a utilizar el interruptor por medio de un programa en lenguaje ensamblador para el
PIC18F4550 para una función determinada.

Desarrollo:

;******************************************************************************

; This file is a basic template for assembly code for a PIC18F4550. Copy *

; this file into your project directory and modify or add to it as needed. *

; *

; The PIC18FXXXX architecture allows two interrupt configurations. This *

; template code is written for priority interrupt levels and the IPEN bit *

; in the RCON register must be set to enable priority levels. If IPEN is *

; left in its default zero state, only the interrupt vector at 0x008 will *

; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not *

; be needed. *

; *

; Refer to the MPASM User's Guide for additional information on the *

; features of the assembler. *

; *

; Refer to the PIC18FXX50/XX55 Data Sheet for additional *

; information on the architecture and instruction set. *

; *

;******************************************************************************

; *

; Filename: PlantillaASM *

; Date: 12/01/11 *

; File Version: 1.0 *

; *

; Author: Ing. Alejandro Vicente Lugo Silva *

; Company: Acad. Computación ICE - ESIME Zac. *


; *

;******************************************************************************

; *

; Files required: P18F4550.INC *

; *

;******************************************************************************

LIST P=18F4550, F=INHX32 ;directive to define processor

#include <P18F4550.INC> ;processor specific variable definitions

;******************************************************************************

;Configuration bits

CONFIG PLLDIV = 5 ;(20 MHz crystal on PICDEM FS USB board)

CONFIG CPUDIV = OSC1_PLL2

CONFIG USBDIV = 2 ;Clock source from 96MHz PLL/2

CONFIG FOSC = HSPLL_HS

CONFIG FCMEN = OFF

CONFIG IESO = OFF

CONFIG PWRT = OFF

CONFIG BOR = ON

CONFIG BORV =3

CONFIG VREGEN = ON ;USB Voltage Regulator

config WDT = OFF

config WDTPS = 32768

config MCLRE = ON

config LPT1OSC = OFF

config PBADEN = OFF ;NOTE: modifying this value here won't have an effect
;on the application. See the top of the
main() function.

;By default the RB4 I/O pin is used to


detect if the

;firmware should enter the bootloader or


the main application

;firmware after a reset. In order to do


this, it needs to

;configure RB4 as a digital input, thereby


changing it from

;the reset value according to this


configuration bit.

config CCP2MX = ON

config STVREN = ON

config LVP = OFF

config ICPRT = OFF ; Dedicated In-Circuit Debug/Programming

config XINST = OFF ; Extended Instruction Set

config CP0 = OFF

config CP1 = OFF

config CP2 = OFF

config CP3 = OFF

config CPB = OFF

config CPD = OFF

config WRT0 = OFF

config WRT1 = OFF

config WRT2 = OFF

config WRT3 = OFF

config WRTB = OFF ; Boot Block Write Protection

config WRTC = OFF

config WRTD = OFF

config EBTR0 = OFF


config EBTR1 = OFF

config EBTR2 = OFF

config EBTR3 = OFF

config EBTRB = OFF

;******************************************************************************

;Variable definitions

; These variables are only needed if low priority interrupts are used.

; More variables may be needed to store other special function registers used

; in the interrupt routines.

;******************************************************************************

;Reset vector

; This code will start executing when a reset occurs.

RESET_VECTOR ORG 0

goto Main ;go to start of main code

;******************************************************************************

;******************************************************************************

;Start of main program

; The main program code is placed here.

ORG 0x1000

Main ; *** main code goes here **

call configptos

call configtimer0
consulta:

btfsc INTCON,TMR0IF

call nuevoretardo

goto consulta

; end of main

;******************************************************************************

; Start of subrutines

;******************************************************************************

configptos ;subrutina define lineas de E/S

movlw 0x0F

movwf ADCON1

clrf TRISA

movlw 0x55

movwf LATA

return

configtimer0 ;subrutina que configura el modo de operaciòn timer0

bcf INTCON,TMR0IF

movlw 0X48

movwf TMR0H

movlw 0XE5

movwf TMR0L

movlw 0X87

movwf T0CON

return

nuevoretardo ;reinici timer para nuevo retardo

bcf INTCON,TMR0IF
movlw 0x48

movwf TMR0H

movlw 0XE5

movwf TMR0L

comf LATA

return

;******************************************************************************

;End of program

END

Diagrama del circuito:


INSTITUTO POLITÉCNICO NACIONAL
ESCUELA SUPERIOR DE INGENIERÍA MECÁNICA Y ELÉCTRICA
UNIDAD ZACATENCO
INGENIERÍA EN COMUNICACIONES Y ELÉCTRONICA

Microprocesadores.
Práctica:
Sumador (Manejo de tablas con PIC 18F4550)

Profesor:
Vázquez Zarate Agustín.
Grupo: 6CV5

Integrantes:
Objetivo:

Desarrollar y diseñar un programa para la suma de números. Y el uso de las tables del PIC
18F4550.

Desarrollo:

;******************************************************************************

; This file is a basic template for assembly code for a PIC18F4550. Copy *

; this file into your project directory and modify or add to it as needed. *

; *

; The PIC18FXXXX architecture allows two interrupt configurations. This *

; template code is written for priority interrupt levels and the IPEN bit *

; in the RCON register must be set to enable priority levels. If IPEN is *

; left in its default zero state, only the interrupt vector at 0x008 will *

; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not *

; be needed. *

; *

; Refer to the MPASM User's Guide for additional information on the *

; features of the assembler. *

; *

; Refer to the PIC18FXX50/XX55 Data Sheet for additional *

; information on the architecture and instruction set. *

; *

;******************************************************************************

; *

; Filename: PlantillaASM *

; Date: 12/01/11 *
; File Version: 1.0 *

; *

; Author: Ing. Alejandro Vicente Lugo Silva *

; Company: Acad. Computación ICE - ESIME Zac. *

; *

;******************************************************************************

; *

; Files required: P18F4550.INC *

; *

;******************************************************************************

LIST P=18F4550, F=INHX32 ;directive to define processor

#include <P18F4550.INC> ;processor specific variable definitions

;#define LED PORTD,3

;******************************************************************************

;Configuration bits

CONFIG PLLDIV = 5 ;(20 MHz crystal on PICDEM FS USB board)

CONFIG CPUDIV = OSC1_PLL2

CONFIG USBDIV = 2 ;Clock source from 96MHz PLL/2

CONFIG FOSC = HSPLL_HS

CONFIG FCMEN = OFF

CONFIG IESO = OFF

CONFIG PWRT = OFF

CONFIG BOR = ON

CONFIG BORV =3

CONFIG VREGEN = ON ;USB Voltage Regulator

config WDT = OFF

config WDTPS = 32768


config MCLRE = ON

config LPT1OSC = OFF

config PBADEN = OFF ;NOTE: modifying this value here won't have an effect

;on the application. See the top of the


main() function.

;By default the RB4 I/O pin is used to


detect if the

;firmware should enter the bootloader or


the main application

;firmware after a reset. In order to do


this, it needs to

;configure RB4 as a digital input, thereby


changing it from

;the reset value according to this


configuration bit.

config CCP2MX = ON

config STVREN = ON

config LVP = OFF

config ICPRT = OFF ; Dedicated In-Circuit Debug/Programming

config XINST = OFF ; Extended Instruction Set

config CP0 = OFF

config CP1 = OFF

config CP2 = OFF

config CP3 = OFF

config CPB = OFF

config CPD = OFF

config WRT0 = OFF

config WRT1 = OFF

config WRT2 = OFF

config WRT3 = OFF

config WRTB = OFF ; Boot Block Write Protection


config WRTC = OFF

config WRTD = OFF

config EBTR0 = OFF

config EBTR1 = OFF

config EBTR2 = OFF

config EBTR3 = OFF

config EBTRB = OFF

;******************************************************************************

;Variable definitions

; These variables are only needed if low priority interrupts are used.

; More variables may be needed to store other special function registers used

; in the interrupt routines.

;******************************************************************************

;Reset vector

; This code will start executing when a reset occurs.

RESET_VECTOR ORG 010

goto Main ;go to start of main code

;******************************************************************************

;******************************************************************************

;Start of main program

; The main program code is placed here.


ORG 0X1000

MOVLW #0FH

MOVWF ADCON1

MOVLW #07H ;0FH POR SI NO JALA

MOVWF TRISB

CLRF TRISD

Main ;go to start of main code

MOVF PORTB,0

ANDLW B'00000111'

CALL TABLA

MOVWF PORTD

GOTO Main

;******************************************************************************

; Start of subrutines

;******************************************************************************

TABLA

MULLW H'02'

MOVF PRODL,W

ADDWF PCL,F

RETLW H'C0' ;DT 0C0H

RETLW H'F9'
RETLW H'A4'

RETLW H'B0'

RETLW H'99'

RETLW H'92'

RETLW H'82'

RETLW H'F8'

;******************************************************************************

;End of program

END

Tabla para identificar las diferencias entre los PIC´s.

You might also like