Académique Documents
Professionnel Documents
Culture Documents
com
*******
; PROGRAMA : X-LCD3310.lib
; Funcion : Libreria Control LCD grafico NOKIA 3310
;
;
; En la variable "rotulo" debemos definir la etiqueta que contiene
; el rotulo que queremos mostrar por ejemplo:
;
; mensaje1 dt "HOLA MUNDO", 0xFD
;
; el byte 0xFD indica el final del rotulo y es del todo necesario.
;
; movlw mensaje1 ;<---- esto define la posicion del
rotulo
; movwf rotulo ;y la guardamos en la variable
"rotulo"
;
; call lee_rotulo ;llamada a la subrutina de lectura
; ;e impresion en el display.
;
; INI_LCD -Inicializa SPI y LCD con la configuracion por defecto
;
; RST_LCD -Resetea el LCD
;
; CLR_LCD -Limpia toda la ram del LCD
;
; X_address -define cursor X en el display para empezar a pintar
; Y_address -define cursor Y en el display para empezar a pintar
;
; Invert_video -Invierte los colores de la pantalla
;
; normal_video -colores normales
;
; TX_SPI_C -Envia comando al LCD
; TX_SPI -Envia dato al LCD
;
;------------------------------------------------------------------------
---
; Revision : 2.00 Fecha: 8/10/2005 Programa para : PIC16F876
; CPU Clock : 4 MHz Tiempo instruccion : 1uS
; WDT : OFF Tipo de reloj : XT
; Code Prot : OFF cfg USART rs232 ; none
; Autor : Daniel C. Martin " ionitron@x-robotics.com "
;************************************************* www.x-robotics.com
*******
movlw 0xFD
subwf caracter,W
btfsc STATUS,Z
return ;finaliza la lectura
call pinta_letra
incf rotulo
goto lee_rotulo
;########################################################################
####
;############### RUTINAS CONTROL LCD NOKIA 3310 Y PUERTO SPI
################
;########################################################################
####
;_______________________Inicializacion del
LCD_______________________________
INI_LCD call CFG_SPI ;configura puerto SPI
movlw d'30'
call delay
call RST_LCD ;primer reset de LCD antes de inic.
call SET_LCD ;inicializacion del LCD
call CLR_LCD ;puesta a cero de la matriz.
movlw d'10'
call delay
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_____________________Configuracion puerto serie
SPI________________________
CFG_SPI bsf STATUS,RP0 ;banco 1 >>>>
movlw b'01000000'
movwf SSPSTAT
bcf STATUS,RP0 ;banco 0 >>>>
movlw b'00000000'
call TX_SPI
decfsz BucleInt ;espera 252 vueltas
goto $-3
decfsz BucleExt ;da 2 x 252 = 504 vueltas
goto Bint
movlw b'00001100' ;mode [Normal mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;___________________________ posicion X
_____________________________________
X_address iorlw b'10000000' ;añade bit de comando
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;___________________________ posicion Y
_____________________________________
Y_address iorlw b'01000000' ;añade bit de comando
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_________________________video
invertido____________________________________
Invert_video movlw b'00001101' ;mode [Inverse video mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_________________________video
normal____________________________________
normal_video movlw b'00001100' ;mode [normal mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;________________Transmision de datos por puerto serie
SPI___________________
TX_SPI_C bcf PORTC,DC ;Modo COMANDO
TX_SPI bcf PORTC,SCE ;enable
display!!!!!!!!!!!!!!!!!!!!!!
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
movf ACCcHI,W
addwf PCLATH,F
movf ACCcLO,W
addwf offset_caractr,W;suma el desplazamiento de columna
para lcd grafico
btfsc STATUS,C ;comprueba acarreo de la suma
incf PCLATH,F ;si se genero acarreo incrementa
PCLATH
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x00
'configurable........
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x01
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x02
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x03
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x04
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x05
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x06
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x07
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x08
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x09
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0A
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0B
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0C
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0D
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0E
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0F
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x10
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x11
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x12
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x13
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x14
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x15
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x16
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x17
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x18
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x19
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1A
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1B
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1C
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1D
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1E
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1F
'configurable........
dt 0x3E,0x51,0x49,0x45,0x3E,0x00 ; 0 0x30
dt 0x0,0x42,0x7F,0x40,0x0,0x00 ; 1 0x31
dt 0x42,0x61,0x51,0x49,0x46,0x00 ; 2 0x32
dt 0x21,0x41,0x45,0x4B,0x31,0x00 ; 3 0x33
dt 0x18,0x14,0x12,0x7F,0x10,0x00 ; 4 0x34
dt 0x27,0x45,0x45,0x45,0x39,0x00 ; 5 0x35
dt 0x3C,0x4A,0x49,0x49,0x30,0x00 ; 6 0x36
dt 0x1,0x1,0x79,0x5,0x3,0x00 ; 7 0x37
dt 0x36,0x49,0x49,0x49,0x36,0x00 ; 8 0x38
dt 0x6,0x49,0x49,0x29,0x1E,0x00 ; 9 0x39
dt 0x0,0x36,0x36,0x0,0x0,0x00 ; : 0x3A
dt 0x0,0x56,0x36,0x0,0x0,0x00 ; ; 0x3B
dt 0x0,0x8,0x14,0x22,0x41,0x00 ; < 0x3C
dt 0x14,0x14,0x14,0x14,0x14,0x00 ; = 0x3D
dt 0x41,0x22,0x14,0x8,0x0,0x00 ; > 0x3E
dt 0x2,0x1,0x51,0x9,0x6,0x00 ; ? 0x3F
dt 0x3E,0x41,0x49,0x55,0x5E,0x00 ; @ 0x40
dt 0x7E,0x11,0x11,0x11,0x7E,0x00 ; A 0x41
dt 0x7F,0x49,0x49,0x49,0x36,0x00 ; B 0x42
dt 0x3E,0x41,0x41,0x41,0x22,0x00 ; C 0x43
dt 0x7F,0x41,0x41,0x22,0x1C,0x00 ; D 0x44
dt 0x7F,0x49,0x49,0x49,0x41,0x00 ; E 0x45
dt 0x7F,0x9,0x9,0x9,0x1,0x00 ; F 0x46
dt 0x3E,0x41,0x49,0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x8,0x8,0x0 ; <-0x7F
;========================================================================
=========
;========================================================================
=========
;========================================================================
=========
;*******************************************************************
; Double Precision Multiplication
;
; ( Optimized for Code Size : Looped Code )
;
;*******************************************************************;
; Multiplication : ACCb(16 bits) * ACCa(16 bits) -> ACCb,ACCc ( 32 bits
)
; (a) Load the 1st operand in location ACCaLO & ACCaHI ( 16 bits )
; (b) Load the 2nd operand in location ACCbLO & ACCbHI ( 16 bits )
; (c) CALL D_mpy
; (d) The 32 bit result is in location ( ACCbHI,ACCbLO,ACCcHI,ACCcLO
)
;*******************************************************************;
;
;
;*******************************************************************
; Double Precision Multiply ( 16x16 -> 32 )
; ( ACCb*ACCa -> ACCb,ACCc ) : 32 bit output with high word
; in ACCb ( ACCbHI,ACCbLO ) and low word in ACCc ( ACCcHI,ACCcLO ).
;
;
;
;*******************************************************************
;
setupmult movlw .16 ; for 16 shifts
movwf temp
movf ACCbHI,W ;move ACCb to ACCd
movwf ACCdHI
movf ACCbLO,W
movwf ACCdLO
clrf ACCbHI
clrf ACCbLO
return
;
;****************************************************************
end1 return
END
;************************************************* www.x-robotics.com
*******
v