title "LcdTerminal 16F873 or 16F628" ; ; ; Hardware Notes: ; 20 MHz osc 115200 baud ; ; Ted Rossin: 04-13-2003 ; 06-05-2003 ; ************************************************ ; ** ** ; ** Special characters: ** ; ** 0x01 Home ** ; ** 0x08 Back space ** ; ** 0x09 Tab ** ; ** 0x0a Line feed ^J ** ; ** 0x0c Form feed (Clear display) ** ; ** 0x0d Carriage return ^M ** ; ** 0x10 Move to X,Y (X and Y are the ** ; ** next two characters ** ; ** 0x1b Escape ** ; ** 0x00 Disable cursor ** ; ** 0x01 Enable underscore cursor ** ; ** 0x02 Enable block cursor ** ; ** 0x03 Scroll display left ** ; ** 0x04 Scroll display right ** ; ** 0x05 Enable Display ** ; ** 0x06 Disable Display ** ; ** 0x07 Raw LCD controller command ** ; ** 0x08 Disable vertical scroll ** ; ** 0x09 Enable vertical scroll(default)** ; ** 0x10 Write Custom character 0 ** ; ** Next 8 bytes form character ** ; ** 0x11 Write Custom character 1 ** ; ** Next 8 bytes form character ** ; ** 0x12 Write Custom character 2 ** ; ** Next 8 bytes form character ** ; ** 0x13 Write Custom character 3 ** ; ** Next 8 bytes form character ** ; ** 0x14 Write Custom character 4 ** ; ** Next 8 bytes form character ** ; ** 0x15 Write Custom character 5 ** ; ** Next 8 bytes form character ** ; ** 0x16 Write Custom character 6 ** ; ** Next 8 bytes form character ** ; ** 0x17 Write Custom character 7 ** ; ** Next 8 bytes form character ** ; ** 0x80 Display custom character 0 ** ; ** 0x81 Display custom character 1 ** ; ** 0x82 Display custom character 2 ** ; ** 0x83 Display custom character 3 ** ; ** 0x84 Display custom character 4 ** ; ** 0x85 Display custom character 5 ** ; ** 0x86 Display custom character 6 ** ; ** 0x87 Display custom character 7 ** ; ** ** ; ************************************************ LIST R=DEC ; Used for development #ifdef __16F873 #include "p16f873.inc" #define LCD_RS PORTC,2 #define LCD_E PORTC,3 #define BAUD_SELECT PORTC,4 __CONFIG _CP_OFF & _DEBUG_OFF & _HS_OSC & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _WRT_ENABLE_ON & _BODEN_ON & _CPD_OFF #endif ; Used for product #ifdef __16F628 #include "P16f628.inc" #define LCD_RS PORTA,2 #define LCD_E PORTA,3 #define BAUD_SELECT PORTA,5 #define _CPD_OFF 0x3fff ; Missing define #define _CPD_ON 0x3eff ; Missing define __CONFIG _HS_OSC & _CP_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF #endif #define PRESCALE_TIMER_MODE 0xD0 #define PRESCALE_VALUE (PRESCALE_TIMER_MODE | 0x8) ; Set prescaler to 1/1 #define TERM_HOME 0x01 ; SOH #define TERM_BS 0x08 ; BS #define TERM_TAB 0x09 ; HTAB #define TERM_LF 0x0a ; LF (Line feed) ^J #define TERM_CLEAR 0x0c ; FF #define TERM_CR 0x0d ; CR (Carriage return) ^M #define TERM_POS 0x10 ; Move to X,Y #define TERM_ESC 0x1b ; More fun ahead #define ESC_DISABLE_CURSOR 0x00 #define ESC_ENABLE_UNDER_CURSOR 0x01 #define ESC_ENABLE_BLOCK_CURSOR 0x02 #define ESC_SCROLL_LEFT 0x03 #define ESC_SCROLL_RIGHT 0x04 #define ESC_ENABLE_DISPLAY 0x05 #define ESC_DISABLE_DISPLAY 0x06 #define ESC_RAW_COMMAND 0x07 #define ESC_DISABLE_VERT_SCROLL 0x08 #define ESC_ENABLE_VERT_SCROLL 0x09 #define ESC_WRITE_CUSTOM 0x10 #define DISPLAY_CUSTOM_MASK 0xf8 #define DISPLAY_CUSTOM_VALUE 0x80 #define STATE_NORMAL 0 #define STATE_WAIT_X 1 #define STATE_WAIT_Y 2 #define STATE_WAIT_COMMAND 3 #define FLAGS_DISABLE_VERT_SCROLL 0 ; RAM #define FIFO_START 0xA0 #define FIFO_END 0xEF #define REG_START 0x020 cblock REG_START _w, _status, _fsr ; Context Register Save Values Amount DelayL,DelayH LcdX,LcdY Tmp,Tmp2 Loop1 Count State Flags LastRS232Byte CgRamAddr Param:2 ; Parameters ; Input FIFO Empty FifoWritePtr FifoReadPtr ; Scroll buffer ScrollBuffer1:20 ScrollBuffer2:20 ScrollBuffer3:20 endc org 0 Startup: nop nop nop goto Main ; ************************************************ ; ** ** ; ** Interrupt handler ** ; ** ** ; ************************************************ org 4 Int: movwf _w ; Save Context Registers movf STATUS, w ; - Assume TMR0 is the only enabled Interrupt movwf _status movf FSR,w movwf _fsr bcf PIR1,RCIF ; Clear the recieved data flag ; Write byte to FIFO to full check movf FifoWritePtr,w movwf FSR movf RCREG,w movwf INDF bcf Empty,0 ; Clear the empty flag incf FifoWritePtr,f movf FifoWritePtr,w sublw FIFO_END btfss STATUS,Z ; Skip if need to wrap write pointer goto IntEnd movlw FIFO_START movwf FifoWritePtr IntEnd: movf _fsr,w ; Restore registers movwf FSR movf _status, w movwf STATUS swapf _w, f swapf _w, w retfie ; ************************************************************************ ; ** ** ; ** GetRS232Byte: Waits for a byte to be received and then returns it ** ; ** in w. ** ; ** ** ; ************************************************************************ GetRS232Byte: btfsc Empty,0 ; Wait for byte to show up. goto $-1 movf FifoReadPtr,w ; Fetch byte from FIFO movwf FSR movf INDF,w movwf Tmp incf FifoReadPtr,f movf FifoReadPtr,w sublw FIFO_END btfss STATUS,Z ; Skip if need to wrap write pointer goto GetRS232ByteEnd movlw FIFO_START movwf FifoReadPtr GetRS232ByteEnd movf FifoReadPtr,w subwf FifoWritePtr,w btfss STATUS,Z goto GetRS232ByteSkip bsf Empty,0 ; Set the empty flag GetRS232ByteSkip movf Tmp,w return ; ************************************************************************ ; ** ** ; ** SendRS232Byte: Waits for transmit to be ready and then sends byte ** ; ** in w to the RS-232 port ** ; ** ** ; ************************************************************************ SendRS232Byte: btfss PIR1,TXIF goto $-1 movwf TXREG return; ; ************************************************************************ ; ** ** ; ** InitRS232: ** ; ** Initialize the RS-232 port for recieve interrupt operation. ** ; ** ** ; ************************************************************************ InitRS232: bcf STATUS,RP0 bcf STATUS,RP1 ; Select Bank 0 bsf STATUS,RP0 ; Select Bank 1 registers #ifdef __16F873 bsf TRISC^0x80,7 ; PORTC[RX] is Input bcf TRISC^0x80,6 ; PORTC[TX] is Output #else bsf TRISB^0x80,1 ; PORTB[RX] is Input bcf TRISB^0x80,2 ; PORTB{TX] is Output #endif bcf STATUS,RP0 ; Select Bank 0 movlw 129 ; Set baud to 9600 btfss BAUD_SELECT ; Check to see if High baud rate movlw 10 ; Set baud to 115200 bsf STATUS,RP0 ; Select Bank 1 registers ; movlw 20 ; Set baud to 57600 movwf SPBRG^0x80 ; movlw (1<<TXEN)|(1<<BRGH) movwf TXSTA^0x80 ; Set transmit mode movlw (1<<RCIE) iorwf PIE1^0x80,f ; Enable receive interrupts bcf STATUS,RP0 ; Select Bank 0 movlw (1<<SPEN)|(1<<CREN) movwf RCSTA ; Set receive mode bsf Empty,0 ; Set the empty flag movlw FIFO_START movwf FifoWritePtr movwf FifoReadPtr return ; ; InitWaitTimer ; InitWaitTimer: bcf STATUS,RP0 bcf STATUS,RP1 movlw 0x01 ; timer 1 internal 1:1 prescale movwf T1CON clrf TMR1L clrf TMR1H return ; ; Waitms ; Waitms: WaitmsLoop: bcf T1CON,0 ; Disable Timer movlw 255-19 movwf TMR1H movlw 255-(136-12) movwf TMR1L bsf T1CON,0 ; Enable Timer WaitmsInnerLoop: btfsc TMR1H,7 goto WaitmsInnerLoop decfsz Amount,f goto WaitmsLoop return; ; ; Waitus ; Waitus: bcf T1CON,0 ; Turn off timer movlw 5 subwf Amount,w movwf DelayL bcf STATUS,C clrf DelayH rlf DelayL,f rlf DelayH,f rlf DelayL,f rlf DelayH,f movlw 5 subwf Amount,w addwf DelayL,f btfsc STATUS,C incf DelayH,f ; {DelayH,DelayL} = Amount*5 movf DelayL,w sublw 255 ; 255-DelayL movwf TMR1L movf DelayH,w sublw 255 movwf TMR1H bsf T1CON,0 ; Turn on Timer movlw 5-1 subwf Amount,w btfss STATUS,C return; ; return if Amount < 5us WaitusLoop: btfsc TMR1H,7 goto WaitusLoop return ; WriteData: #ifdef __16F873 movwf PORTB #else ; Swizzle byte data between PORT A and B ; {PB7,PB6,PB5,PB4,PB3,PB0,PA1,PA0} = w[7:0] movwf Tmp andlw 0xfc movwf PORTB btfsc Tmp,2 bsf PORTB,0 movf Tmp,w andlw 0x03 movwf Param movf PORTA,w andlw 0xfc iorwf Param,w movwf PORTA #endif return ; ; Writes the character in W to LCD display ; LcdPutChar: movwf Tmp call WriteData bsf LCD_RS bsf LCD_E nop bcf LCD_E ; Save data in Scroll Buffer movf LcdY,w addlw 0-0 ; Check for 0 btfsc STATUS,Z goto LcdPutCharFinish movf LcdY,w addlw 256-1 ; Check for 1 btfsc STATUS,Z goto LcdPutCharLine1 movf LcdY,w addlw 256-2 ; Check for 2 btfsc STATUS,Z goto LcdPutCharLine2 goto LcdPutCharLine3 LcdPutCharLine1: movlw ScrollBuffer1 goto LcdPutCharSave LcdPutCharLine2: movlw ScrollBuffer2 goto LcdPutCharSave LcdPutCharLine3 movlw ScrollBuffer3 LcdPutCharSave: movwf FSR movf LcdX,w addwf FSR,f movf Tmp,w movwf INDF ; Write data into buffer LcdPutCharFinish: incf LcdX,f movlw 40 movwf Amount call Waitus return ; ; LcdWriteCommand: Writes the command in w to the LCD disply ; LcdWriteCommand: movwf Tmp call WriteData bcf LCD_RS bsf LCD_E nop bcf LCD_E movlw 40 movwf Amount call Waitus return ; ; LcdClearDisplay: Clears LCD display ; LcdClearDisplay: movlw 0x01 ; Clear display call WriteData bcf LCD_RS bsf LCD_E nop bcf LCD_E clrf LcdX clrf LcdY movlw 2 movwf Amount call Waitms return ; ; InitLcd: Initializes LCD display ; LcdInit: bcf LCD_RS ; Turn off stobes to LCD display bcf LCD_E ; Clear scroll buffers clrf Count movlw 20 movwf Loop1 LcdInitLoop: movlw ScrollBuffer1 movwf FSR movf Count,w addwf FSR,f movlw ' ' ; Replace with blank movwf INDF movlw ScrollBuffer2 movwf FSR movf Count,w addwf FSR,f movlw ' ' ; Replace with blank movwf INDF movlw ScrollBuffer3 movwf FSR movf Count,w addwf FSR,f movlw ' ' ; Replace with blank movwf INDF incf Count,f decfsz Loop1,f goto LcdInitLoop movlw 100 movwf Amount call Waitms ; Wait for LCD to power up call LcdClearDisplay movlw 0x38 ; Set Function call LcdWriteCommand movlw 0x0c ; Turn on display (no cursor) call LcdWriteCommand movlw 0x06 ; Set Entry Mode call LcdWriteCommand return ; ; LcdSetPos ; LcdSetPos: movlw 0x80 ; Lcd Set Addr Command addwf LcdX,w ; Add X offset btfsc LcdY,0 addlw 0x40 ; Odd line Y offset btfsc LcdY,1 addlw 0x14 ; Lines 2 and 3 offset movwf Tmp call WriteData bcf LCD_RS bsf LCD_E nop bcf LCD_E movlw 40 movwf Amount call Waitus return #ifdef FLASH_MEMORY_ACCESS ; ; LcdDisplayString(Param+1,Param+0) {Param+1,param+0} form 16-bit address pointer ; The string must be located in flash memory code space ; LcdDisplayString: movf Param+1,w ; Fetch low address (assume bank 0) bsf STATUS,RP1 bcf STATUS,RP0 ; Bank2 movwf EEADR^0x100 ; Set low address bcf STATUS,RP1 ; Bank 0 movf Param+0,w bsf STATUS,RP1 ; Bank 2 movwf EEADRH^0x100 ; Set high address LcdDisplayStringLoop: bsf STATUS,RP0 ; Bank3 bsf EECON1^0x180,EEPGD ; Point to Program memory bsf EECON1^0x180,RD ; Start read operation nop ; two required NOPs nop bcf STATUS,RP0 ; Bank2 movf EEDATA^0x100,w ; Fetch Low Byte bcf STATUS,RP1 ; Bank0 addlw 0 ; Check for end of string btfsc STATUS,Z return ; End of string addlw 256-'\n' ; Check for \n btfsc STATUS,Z goto LcdDisplayStringNewLine addlw '\n' ; Restore check value call LcdPutChar LcdDisplayStringAdvance: bsf STATUS,RP1 ; Bank 2 incf EEADR^0x100,f ; Advance read pointer btfsc STATUS,Z incf EEADRH^0x100,f ; Advance high order address if overflow goto LcdDisplayStringLoop LcdDisplayStringNewLine: clrf LcdX incf LcdY,f call LcdSetPos ; Goto (LcdX,LcdY) goto LcdDisplayStringAdvance #endif ; ; Main Program ; Main: bcf STATUS,RP0 bcf STATUS,RP1 call InitWaitTimer bcf STATUS,RP1 bsf STATUS,RP0 ; Select Bank 1 #ifdef __16F873 movlw 0x2f ; Port A[3:0],A[5] are input for A/D movwf TRISA^0x80 clrf TRISB^0x80 ; PORTB is Output movlw 0x10 ; Output PORTC[7:5],PORTC[3:0], Input PORTC[4] movwf TRISC^0x80 movlw 0x00 ; (left justified data) 8 or 5 A/D channels movwf ADCON1^0x80 bcf STATUS,RP0 ; Go back to Bank 0 movlw 0x81 ; FOSC/32, channel=0, ADON=1 movwf ADCON0 #else bcf STATUS,RP0 ; Select Bank 0 movlw 0x07 movwf CMCON ; Turn off 16F82x comparators to save power bsf STATUS,RP0 ; Select Bank 1 movlw 0x20 ; Port A[4] is input, Port A[3:0] are output movwf TRISA^0x80 ; PORTA is Output clrf TRISB^0x80 ; PORTB is Output #endif bsf STATUS,RP0 ; Go to Bank 1 movlw PRESCALE_VALUE ; Set Timer 0 prescale value movwf OPTION_REG^0x080 bcf STATUS,RP0 ; Go back to Bank 0 call LcdInit call LcdClearDisplay call InitRS232 ; Initialize varibles clrf LcdX clrf LcdY clrf LastRS232Byte clrf Flags movlw STATE_NORMAL movwf State movlw (1<<GIE) | (1<<PEIE) movwf INTCON ; Enable Interrupts TheLoop: movf State,w addlw STATE_NORMAL ; Check btfsc STATUS,Z goto NormalState addlw STATE_NORMAL ; Restore check value addlw 256-STATE_WAIT_X ; Check btfsc STATUS,Z goto WaitXState addlw STATE_WAIT_X ; Restore check value addlw 256-STATE_WAIT_Y ; Check btfsc STATUS,Z goto WaitYState addlw STATE_WAIT_Y ; Restore check value addlw 256-STATE_WAIT_COMMAND ; Check btfsc STATUS,Z goto EscCommand addlw STATE_WAIT_COMMAND ; Restore check value goto TheLoop WaitXState: call GetRS232Byte movwf LcdX movlw STATE_WAIT_Y movwf State goto TheLoop WaitYState: call GetRS232Byte movwf LcdY movlw STATE_NORMAL movwf State call LcdSetPos ; Goto (LcdX,LcdY) goto TheLoop ; ; Process Esc command ; EscCommand: movlw STATE_NORMAL movwf State call GetRS232Byte addlw ESC_DISABLE_CURSOR ; Check btfsc STATUS,Z goto DisableCursor addlw ESC_DISABLE_CURSOR ; Restore check value addlw 256-ESC_ENABLE_UNDER_CURSOR ; Check btfsc STATUS,Z goto EnableUnderCursor addlw ESC_ENABLE_UNDER_CURSOR ; Restore check value addlw 256-ESC_ENABLE_BLOCK_CURSOR ; Check btfsc STATUS,Z goto EnableBlockCursor addlw ESC_ENABLE_BLOCK_CURSOR ; Restore check value addlw 256-ESC_SCROLL_LEFT ; Check btfsc STATUS,Z goto ScrollLeft addlw ESC_SCROLL_LEFT ; Restore check value addlw 256-ESC_SCROLL_RIGHT ; Check btfsc STATUS,Z goto ScrollRight addlw ESC_SCROLL_RIGHT ; Restore check value addlw 256-ESC_ENABLE_DISPLAY ; Check btfsc STATUS,Z goto EnableDisplay addlw ESC_ENABLE_DISPLAY ; Restore check value addlw 256-ESC_DISABLE_DISPLAY ; Check btfsc STATUS,Z goto DisableDisplay addlw ESC_DISABLE_DISPLAY ; Restore check value addlw 256-ESC_RAW_COMMAND ; Check btfsc STATUS,Z goto RawCommand addlw ESC_RAW_COMMAND ; Restore check value addlw 256-ESC_DISABLE_VERT_SCROLL ; Check btfsc STATUS,Z goto DisableVertScroll addlw ESC_DISABLE_VERT_SCROLL ; Restore check value addlw 256-ESC_ENABLE_VERT_SCROLL ; Check btfsc STATUS,Z goto EnableVertScroll addlw ESC_ENABLE_VERT_SCROLL ; Restore check value movwf LastRS232Byte andlw DISPLAY_CUSTOM_MASK addlw 256-ESC_WRITE_CUSTOM ; Check btfsc STATUS,Z goto WriteCustomChar movf LastRS232Byte,w goto TheLoop DisableCursor: movlw 0x0c call LcdWriteCommand goto TheLoop EnableUnderCursor: movlw 0x0e call LcdWriteCommand goto TheLoop EnableBlockCursor: movlw 0x0f call LcdWriteCommand goto TheLoop ScrollLeft: movlw 0x18 call LcdWriteCommand goto TheLoop ScrollRight: movlw 0x1c call LcdWriteCommand goto TheLoop EnableDisplay: movlw 0x0c call LcdWriteCommand goto TheLoop DisableDisplay: movlw 0x08 call LcdWriteCommand goto TheLoop RawCommand: movf LastRS232Byte,w call LcdWriteCommand goto TheLoop DisableVertScroll: bsf Flags,FLAGS_DISABLE_VERT_SCROLL goto TheLoop EnableVertScroll: bcf Flags,FLAGS_DISABLE_VERT_SCROLL goto TheLoop WriteCustomChar: movf LastRS232Byte,w andlw 0x7 ; Just get character ID movwf CgRamAddr bcf STATUS,C rlf CgRamAddr,f rlf CgRamAddr,f rlf CgRamAddr,f ; Set character Ram address movlw 8 movwf Count WriteCustomCharLoop: movf CgRamAddr,w iorlw 0x40 call LcdWriteCommand call GetRS232Byte call LcdPutChar ; Write the data decf LcdX,f ; undo inc of LcdX incf CgRamAddr,f decfsz Count,f goto WriteCustomCharLoop ; Go back to normal character mode call LcdSetPos ; Goto (LcdX,LcdY) goto TheLoop ; ; Normal single character ; NormalState: call GetRS232Byte ; Lame case statement addlw 256-TERM_LF ; Check for \n btfsc STATUS,Z goto PreTerminalNewLine1 addlw TERM_LF ; Restore check value addlw 256-TERM_CR ; Check for \r btfsc STATUS,Z goto PreTerminalNewLine2 addlw TERM_CR ; Restore check value movwf LastRS232Byte addlw 256-TERM_BS ; Check for BS btfsc STATUS,Z goto TerminalBackSpace addlw TERM_BS ; Restore check value addlw 256-TERM_HOME ; Check btfsc STATUS,Z goto TerminalHome addlw TERM_HOME ; Restore check value addlw 256-TERM_CLEAR ; Check btfsc STATUS,Z goto TerminalClear addlw TERM_CLEAR ; Restore check value addlw 256-TERM_TAB ; Check btfsc STATUS,Z goto TerminalTab addlw TERM_TAB ; Restore check value addlw 256-TERM_POS ; Check btfsc STATUS,Z goto TerminalPos addlw TERM_POS ; Restore check value addlw 256-TERM_ESC ; Check btfsc STATUS,Z goto TerminalEscape addlw TERM_ESC ; Restore check value movf LcdX,w addlw 256-20 btfsc STATUS,Z call TerminalNewLine movf LastRS232Byte,w andlw DISPLAY_CUSTOM_MASK addlw 256-DISPLAY_CUSTOM_VALUE ; Check btfsc STATUS,Z goto DisplayCustomChar movf LastRS232Byte,w call LcdPutChar goto TheLoop PreTerminalNewLine1: ; \n received movf LastRS232Byte,w addlw 256-TERM_CR ; Check for previous \r btfsc STATUS,Z goto TheLoop movlw TERM_LF movwf LastRS232Byte PreTerminalNewLine: call TerminalNewLine goto TheLoop PreTerminalNewLine2: ; \r received movf LastRS232Byte,w addlw 256-TERM_LF ; Check for previous \n btfsc STATUS,Z goto TheLoop movlw TERM_CR movwf LastRS232Byte call TerminalNewLine goto TheLoop TerminalNewLine: clrf LcdX incf LcdY,f movf LcdY,w addlw 256-4 ; Check for need to scroll btfsc STATUS,Z call ScrollDisplay call LcdSetPos ; Goto (LcdX,LcdY) return TerminalBackSpace: movf LcdX,w addlw 0 ;Check for zero btfsc STATUS,Z goto TheLoop decf LcdX,f call LcdSetPos ; Goto (LcdX,LcdY) movlw ' ' call LcdPutChar ; Remove character decf LcdX,f call LcdSetPos ; Goto (LcdX,LcdY) goto TheLoop TerminalHome: clrf LcdX clrf LcdY call LcdSetPos ; Goto (LcdX,LcdY) goto TheLoop TerminalClear: call LcdClearDisplay goto TheLoop TerminalTab: movf LcdX,w addlw 4 andlw 0xfc ; Snap to tab stop movwf LcdX ; Save new value addlw 256-20 btfsc STATUS,Z goto PreTerminalNewLine call LcdSetPos goto TheLoop TerminalPos: movlw STATE_WAIT_X movwf State goto TheLoop TerminalEscape: movlw STATE_WAIT_COMMAND movwf State goto TheLoop DisplayCustomChar: movlw DISPLAY_CUSTOM_VALUE subwf LastRS232Byte,w ; w = LastRS232Byte - DISPLAY_CUSTOM_MASK call LcdPutChar goto TheLoop ;************************************************* ;** ** ;** ScrollDisplay: ** ;** ** ;************************************************* ScrollDisplay: btfsc Flags,FLAGS_DISABLE_VERT_SCROLL goto DoNotScrollDisplay call LcdClearDisplay clrf Count movlw 20 movwf Loop1 ScrollDisplayLoop1: movlw ScrollBuffer1 movwf FSR movf Count,w addwf FSR,f movf INDF,w call LcdPutChar incf Count,f decfsz Loop1,f goto ScrollDisplayLoop1 clrf LcdX incf LcdY,f call LcdSetPos ; Goto (LcdX,LcdY) clrf Count movlw 20 movwf Loop1 ScrollDisplayLoop2: movlw ScrollBuffer2 movwf FSR movf Count,w addwf FSR,f movf INDF,w call LcdPutChar incf Count,f decfsz Loop1,f goto ScrollDisplayLoop2 ; Copy line 3 to line 2 and clear line 3 buffer clrf LcdX incf LcdY,f call LcdSetPos ; Goto (LcdX,LcdY) clrf Count movlw 20 movwf Loop1 ScrollDisplayLoop3: movlw ScrollBuffer3 movwf FSR movf Count,w addwf FSR,f movf INDF,w movwf Tmp movlw ' ' ; Replace with blank movwf INDF movf Tmp,w call LcdPutChar incf Count,f decfsz Loop1,f goto ScrollDisplayLoop3 DoNotScrollDisplay: clrf LcdX movlw 3 movwf LcdY return; end
file: /Techref/microchip/io/dev/lcd/LcdTerminal.asm, 24KB, , updated: 2003/9/10 11:39, local time: 2024/11/17 13:26,
3.139.85.35:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/microchip/io/dev/lcd/LcdTerminal.asm"> microchip io dev lcd LcdTerminal</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.