Lcd

6

Click here to load reader

Transcript of Lcd

Page 1: Lcd

;******************************************************************************; 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

Page 2: Lcd

;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.

CONTA equ 0x01CONTA2 equ 0x02;******************************************************************************;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 0x1000Main ; *** main code goes here **CALL configptosCALL lcdiniotra;call posmensaje1

call mensaje1

call limpia

Page 3: Lcd

goto otra

; end of main;******************************************************************************; Start of subrutines;******************************************************************************;*****Mensaje 1mensaje1

movlw 0x00movwf TBLPTRUmovlw 0x12movwf TBLPTRH

movlw 0x00movwf CONTAotra1movf CONTA,Wmovwf TBLPTRLTBLRD*movf TABLAT,Wmovwf LATDcall datocall timer_.5spreg10btfss INTCON,TMR0IFGOTO preg10incf CONTAmovlw 0x04CPFSEQ CONTA,Wgoto otra1return;************* Tabla1

ORG 0x1200tabla DB 0X48,0X4f,0X4C,0X41return

;****LCD INICIOlcdinicall timer_20mspregbtfss INTCON,TMR0IFGOTO pregmovlw 0x30movwf LATDcall comandocall timer_5mspreg1btfss INTCON,TMR0IFGOTO preg1movlw 0x30movwf LATDcall comando

Page 4: Lcd

call timer_1mspreg2btfss INTCON,TMR0IFGOTO preg2movlw 0x30movwf LATDcall comandomovlw 0x3Cmovwf LATDcall comando

;movlw 0x07;movwf LATD;call comando

movlw 0x0Fmovwf LATDcall comando

movlw 0x01movwf LATDcall comando

RETURN

;*******comandocomandoBCF LATA,1BCF LATA,0BSF LATA,1call timer_100uspreg3btfss INTCON,TMR0IFGOTO preg3BCF LATA,1return;*******DATOdatoBCF LATA,1BSF LATA,0BSF LATA,1call timer_1mspreg4btfss INTCON,TMR0IFGOTO preg4BCF LATA,1return;*******LIMPIAlimpiamovlw 0x01movwf LATDcall comandoreturn

;*****POSMENSAJE1posmensaje1;call comandomovlw 0x86

Page 5: Lcd

movwf LATDcall comandoreturn

;*******TIMER20ms

timer_20msBCF INTCON,TMR0IFMOVLW 0XFCMOVWF TMR0HMOVLW 0X57MOVWF TMR0LMOVLW 0X87MOVWF T0CONRETURN

;*******TIMER5ms

timer_5msBCF INTCON,TMR0IFMOVLW 0XFFMOVWF TMR0HMOVLW 0X16MOVWF TMR0LMOVLW 0X87MOVWF T0CONRETURN;*******TIMER0.5s

timer_.5sBCF INTCON,TMR0IFMOVLW 0XA4MOVWF TMR0HMOVLW 0X73MOVWF TMR0LMOVLW 0X87MOVWF T0CONRETURN

;*******TIMER 1mstimer_1msBCF INTCON,TMR0IFMOVLW 0XFFMOVWF TMR0HMOVLW 0XD2MOVWF TMR0LMOVLW 0X87MOVWF T0CONRETURN;*******TIMER100useg

timer_100usBCF INTCON,TMR0IFMOVLW 0XFFMOVWF TMR0HMOVLW 0XFCMOVWF TMR0LMOVLW 0X87

Page 6: Lcd

MOVWF T0CONRETURN;*******TIMER

timerBCF INTCON,TMR0IFMOVLW 0X48MOVWF TMR0HMOVLW 0XE5MOVWF TMR0LMOVLW 0X87MOVWF T0CONRETURN;************

configptosmovlw 0x0Fmovwf ADCON1movlw 0x07movwf CMCONmovlw 0x00movwf TRISAmovlw 0x00movwf TRISDreturn;******************************************************************************;End of program

END