;=============================================================================== ; Filename: vdisplay.inc ; Date: 18/06/2003 ; File Version: 1.0 para QRP QB a pedido de PY2RLM ; Original file: OM3CPH ; Author: Vila Real ; Company: WVR-2000 ;================================================================================ ; Files required: ;================================================================================ ; Notes: ;================================================================================ ;================================================================================ ;CONSTANTS DEFINITIONS ;================================================================================ ;LCD Control lines LCD_RS equ 2 ;Register Select LCD_E equ 3 ;Enable ;LCD data line bus LCD_DB4 equ 4 ;LCD data line DB4 LCD_DB5 equ 5 ;LCD data line DB5 LCD_DB6 equ 6 ;LCD data line DB6 LCD_DB7 equ 7 ;LCD data line DB7 ;================================================================================= ;Rotina de retardo, onde w=tempo em ms - clock=20MHz ;================================================================================= LcdDelay movwf LcdDelayCounter+1 ;duas variáveis em uma clrf LcdDelayCounter+0 ;return ;retorno p/debug***************** LcdDelayLoop ;goto $+1 ;1 ms (about) internal loop ;goto $+1 ;equivale a 2xnop ;goto $+1 ;todas linhas comentadas ;goto $+1 ;p/ 4Mhz ;goto $+1 ; ;goto $+1 ; ;goto $+1 ; ;goto $+1 ; nop ; decfsz LcdDelayCounter+0,F ;dec. o prim. cont. goto LcdDelayLoop decfsz LcdDelayCounter+1,F ;dec. o seg. cont. goto LcdDelayLoop return ;================================================================================= ;Rotinas de controle do LCD ;================================================================================= LcdInit movlw 30 ;Wait 30 ms call LcdDelay bcf PORTB,LCD_RS ;Set LCD command mode bsf PORTB,LCD_DB4 ;0011->48 bsf PORTB,LCD_DB5 bcf PORTB,LCD_DB6 bcf PORTB,LCD_DB7 call LcdPulse_E ;sequência de reset call LcdPulse_E call LcdPulse_E bcf PORTB,LCD_DB4 ;0010->32 bsf PORTB,LCD_DB5 bcf PORTB,LCD_DB6 bcf PORTB,LCD_DB7 call LcdPulse_E movlw 28H ;Set 4 bit data bus length call LcdSendCommand movlw 06H ;Entry mode set, increment, no shift call LcdSendCommand movlw 0CH ;Display ON, Curson OFF, Blink OFF call LcdSendCommand call LcdClear ;clear display return LcdClear movlw 01H call LcdSendCommand movlw 2 ;Wait 2 ms call LcdDelay return LcdLocate movwf tmpLcdRegister+0 ;Locate cursor on LCD movlw 80H ;W = D7-D4 row, D3-D0 col movwf tmpLcdRegister+1 ;00h=linha0/10h=linha1 movf tmpLcdRegister+0,W andlw 0FH iorwf tmpLcdRegister+1,F btfsc tmpLcdRegister+0,4 bsf tmpLcdRegister+1,6 movf tmpLcdRegister+1,W call LcdSendCommand return LcdSendData bsf PORTB,LCD_RS call LcdSendByte return LcdSendCommand bcf PORTB,LCD_RS call LcdSendByte return LcdSendByte movwf tmpLcdRegister ;Send a byte to LCD by 4 bit data bus bcf PORTB,LCD_DB4 ;Send highter four bits bcf PORTB,LCD_DB5 bcf PORTB,LCD_DB6 bcf PORTB,LCD_DB7 btfsc tmpLcdRegister,4 bsf PORTB,LCD_DB4 btfsc tmpLcdRegister,5 bsf PORTB,LCD_DB5 btfsc tmpLcdRegister,6 bsf PORTB,LCD_DB6 btfsc tmpLcdRegister,7 bsf PORTB,LCD_DB7 call LcdPulse_E bcf PORTB,LCD_DB4 ;Send lower four bits bcf PORTB,LCD_DB5 bcf PORTB,LCD_DB6 bcf PORTB,LCD_DB7 btfsc tmpLcdRegister,0 bsf PORTB,LCD_DB4 btfsc tmpLcdRegister,1 bsf PORTB,LCD_DB5 btfsc tmpLcdRegister,2 bsf PORTB,LCD_DB6 btfsc tmpLcdRegister,3 bsf PORTB,LCD_DB7 call LcdPulse_E return LcdShiftL movlw 18h ;Shift Mensagem call LcdSendCommand movlw 150 call LcdDelay return LcdPulse_E bsf PORTB,LCD_E ;Enables LCD movlw 1 ;Wait 1ms call LcdDelay bcf PORTB,LCD_E ;Disabled LCD movlw 1 ;Wait 1ms call LcdDelay return ;=============================================================================== ;Rotinas genéricas ;=============================================================================== ShowLoad movlw 00H ;Locate LCD cursor on row 0, col 0 call LcdLocate movlw 'L' ;Shows "Loading..." string on LCD call LcdSendData movlw 'o' call LcdSendData movlw 'a' call LcdSendData movlw 'd' call LcdSendData movlw 'i' call LcdSendData movlw 'n' call LcdSendData movlw 'g' call LcdSendData movlw '.' call LcdSendData movlw '.' call LcdSendData movlw '.' call LcdSendData movlw 255 ;retardo p/ efeito call LcdDelay movlw 10H ;Locate LCD cursor on row 1, col 0 call LcdLocate movlw 13 ;número de vezes que o caracter vai movwf temp ;se repetir PutChar movlw '#' ;carácter a ser impresso call LcdSendData movlw 255 call LcdDelay decfsz temp,f goto PutChar movlw 255 ;retardo p/ efeito call LcdDelay call LcdClear ;limpa LCD return ShowName movlw 00H ;Locate LCD cursor on row 0, col 0 call LcdLocate movlw 'F' ;Shows "WVR-2002" string on LCD call LcdSendData movlw 'R' call LcdSendData movlw 'E' call LcdSendData movlw 'Q' call LcdSendData movlw 'U' call LcdSendData movlw 'E' call LcdSendData movlw 'N' call LcdSendData movlw 'C' call LcdSendData movlw 'I' call LcdSendData movlw 'A' call LcdSendData movlw ' ' call LcdSendData movlw 255 ;retardo p/ efeito call LcdDelay movlw 255 call LcdDelay return ShowHello movlw 10H ;Locate LCD cursor on row 1, col 0 call LcdLocate movlw 'Q' ;Shows "HELLO WORLD" string on LCD call LcdSendData movlw 'R' call LcdSendData movlw 'P' call LcdSendData movlw ' ' call LcdSendData movlw 'B' call LcdSendData movlw 'R' call LcdSendData movlw ' ' call LcdSendData movlw 'F' call LcdSendData movlw 'R' call LcdSendData movlw 'E' call LcdSendData movlw 'Q' call LcdSendData movlw ' ' call LcdSendData movlw '!' call LcdSendData movlw 255 ;retardo p/ efeito call LcdDelay movlw 255 call LcdDelay movlw 255 call LcdDelay movlw 255 call LcdDelay return