You are on page 1of 6

;****************************************************************************** ; 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. Computacin ICE - ESIME Zac. * ; * ;****************************************************************************** ; * ; Files required: P18F4550.INC * ; * ;****************************************************************************** LIST P=18F4550, F=INHX32 #include <P18F4550.INC> ;directive to define processor ;processor specific variable definitions

;****************************************************************************** ;Configuration bits CONFIG PLLDIV CONFIG CPUDIV = CONFIG USBDIV = CONFIG FOSC = CONFIG FCMEN = CONFIG IESO = CONFIG PWRT = CONFIG BOR = CONFIG BORV = CONFIG VREGEN = config WDT = config WDTPS = config MCLRE = config LPT1OSC = config PBADEN = ave an effect = 5 ;(20 MHz crystal on PICDEM FS USB board) OSC1_PLL2 2 ;Clock source from 96MHz PLL/2 HSPLL_HS OFF OFF OFF ON 3 ON ;USB Voltage Regulator OFF 32768 ON OFF OFF ;NOTE: modifying this value here won't h ;on the applic ation. See the top of the main() function. ;By default th e RB4 I/O pin is used to detect if the ;firmware shou ld enter the bootloader or the main application

;firmware afte r a reset. In order to do this, it needs to ;configure RB4 as a digital input, thereby changing it from ;the reset val ue 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. CONTA equ 0x01 CONTA2 equ 0x02 ;****************************************************************************** ;Reset vector ; This code will start executing when a reset occurs. RESET_VECTOR ORG goto Main 0 ;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 lcdini otra ;call posmensaje1 call mensaje1 call limpia

goto otra ; end of main ;****************************************************************************** ; Start of subrutines ;****************************************************************************** ;*****Mensaje 1 mensaje1 movlw movwf movlw movwf 0x00 TBLPTRU 0x12 TBLPTRH

movlw 0x00 movwf CONTA otra1 movf CONTA,W movwf TBLPTRL TBLRD* movf TABLAT,W movwf LATD call dato call timer_.5s preg10 btfss INTCON,TMR0IF GOTO preg10 incf CONTA movlw 0x04 CPFSEQ CONTA,W goto otra1 return ;************* Tabla1 ORG 0x1200 tabla DB 0X48,0X4f,0X4C,0X41 return

;****LCD INICIO lcdini call timer_20ms preg btfss INTCON,TMR0IF GOTO preg movlw 0x30 movwf LATD call comando call timer_5ms preg1 btfss INTCON,TMR0IF GOTO preg1 movlw 0x30 movwf LATD call comando

call timer_1ms preg2 btfss INTCON,TMR0IF GOTO preg2 movlw 0x30 movwf LATD call comando movlw 0x3C movwf LATD call comando ;movlw 0x07 ;movwf LATD ;call comando movlw 0x0F movwf LATD call comando movlw 0x01 movwf LATD call comando RETURN ;*******comando comando BCF LATA,1 BCF LATA,0 BSF LATA,1 call timer_100us preg3 btfss INTCON,TMR0IF GOTO preg3 BCF LATA,1 return ;*******DATO dato BCF LATA,1 BSF LATA,0 BSF LATA,1 call timer_1ms preg4 btfss INTCON,TMR0IF GOTO preg4 BCF LATA,1 return ;*******LIMPIA limpia movlw 0x01 movwf LATD call comando return ;*****POSMENSAJE1 posmensaje1 ;call comando movlw 0x86

movwf LATD call comando return ;*******TIMER20ms timer_20ms BCF INTCON,TMR0IF MOVLW 0XFC MOVWF TMR0H MOVLW 0X57 MOVWF TMR0L MOVLW 0X87 MOVWF T0CON RETURN ;*******TIMER5ms timer_5ms BCF INTCON,TMR0IF MOVLW 0XFF MOVWF TMR0H MOVLW 0X16 MOVWF TMR0L MOVLW 0X87 MOVWF T0CON RETURN ;*******TIMER0.5s timer_.5s BCF INTCON,TMR0IF MOVLW 0XA4 MOVWF TMR0H MOVLW 0X73 MOVWF TMR0L MOVLW 0X87 MOVWF T0CON RETURN ;*******TIMER 1ms timer_1ms BCF INTCON,TMR0IF MOVLW 0XFF MOVWF TMR0H MOVLW 0XD2 MOVWF TMR0L MOVLW 0X87 MOVWF T0CON RETURN ;*******TIMER100useg timer_100us BCF INTCON,TMR0IF MOVLW 0XFF MOVWF TMR0H MOVLW 0XFC MOVWF TMR0L MOVLW 0X87

MOVWF T0CON RETURN ;*******TIMER timer BCF INTCON,TMR0IF MOVLW 0X48 MOVWF TMR0H MOVLW 0XE5 MOVWF TMR0L MOVLW 0X87 MOVWF T0CON RETURN ;************ configptos movlw 0x0F movwf ADCON1 movlw 0x07 movwf CMCON movlw 0x00 movwf TRISA movlw 0x00 movwf TRISD return ;****************************************************************************** ;End of program END

You might also like