; GPR's (General Purpose Registers) are used for the following: ;H070 and H071: counters for short delay and utility delay ;H072 used to temporarily store characters ;H075 used as offset counter in our tables. list p=16F1455 ; list directive to define processor #include "p16F1455.inc" ; processor specific variable definitions __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON __CONFIG _CONFIG2, _WRT_OFF & _CPUDIV_NOCLKDIV & _USBLSCLK_48MHz & _PLLMULT_3x & _PLLEN_DISABLED & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_ON errorlevel -302 , -207 ; suppress message 302 from list file banksel OSCCON movlw B'00101110' ; we need to slow down the processor for the LCD display driver. Max 2 Mhz. We'll run at 1 Mhz movwf OSCCON ; everything above this line is simply setting up the processor at 1 MHz. banksel TRISA ; set up PORTA for outputs clrf TRISA banksel LATA ; Don't forget this! LATA and TRISA are NOT in the same bank, though they are both for the same register! clrf LATA ;this sends out RS=0 and E=0 from PORTA to the control lines on the LCD display call utility_delay ; waits about 0.8 seconds for display to initialize banksel TRISC clrf TRISC ; we can now set PORTC to all outputs ; we'll now set the display to 4 bit mode ;NOTE: all binary numbers must include all 8 bits. However, only the lower 4 bits are actually connected and therefore, used banksel LATC movlw B'00000010' ;send first command for 4 bit mode. The lower nibble is actually 0000, but not connected. This is the upper nibble movwf LATC call pulse_e banksel LATC movlw B'00000010' ;send upper nibble command to 4 bit mode. movwf LATC call pulse_e ; We are now in 4 bit mode. banksel LATC movlw B'00001100' ;send lower nibble command to 4 bit mode and two line mode. movwf LATC call pulse_e ; we are now in 4 bit, 2 line mode. banksel LATC movlw B'00000000' ;send upper nibble to turn on display, set cursor. movwf LATC call pulse_e banksel LATC movlw B'00001111' ;send lower nibble to turn on display, set cursor. movwf LATC call pulse_e ; The display is now turned on, with a flashing underline cursor at the current character location banksel LATA bsf LATA,4 ; sets RS to 1, putting it into CHARACTER mode banksel LATC ;##############manually add a capital A################# ;This section manually adds a capital A to the display at the current cursor location. ;Simply copy and paste this section for every letter you wish to add. movlw B'00000100' ;first nibble of first character, a capital A movwf LATC call pulse_e banksel LATC movlw B'00000001' ; the second nibble of capital A is loaded onto LATC movwf LATC call pulse_e ;##############end of manually add a capital A################# ;##############manually add another letter################# ;As you can see, I've simply copied and pasted the code to add a second letter. ;Simply copy and paste e code section for every letter you wish to add, leave out the comments if you want. movlw B'00000100' ;first nibble of first character, a capital C - just look at yer fancy high-tech ASCII chart to figure out your nibbles movwf LATC call pulse_e banksel LATC movlw B'00000011' ; the second nibble of capital C is loaded onto LATC movwf LATC call pulse_e ;##############end of manually add a capital A################# endless_loop goto endless_loop utility_delay: ; this subroutine is a utility delay that counts down from 255 255 times. That's a total count of 65025. It takes approximately 0.8 seconds at 1 MHz movlw D'255' movwf H'070' ; load 255 into first register movlw D'255' movwf H'071' ; load 255 into second register subloop: decfsz H'070', 1 ; count down in first register till we hit 0 goto subloop movlw D'255' movwf H'070' ; load 255 into first register again decfsz H'071', 1 ; count down 1 on second register. If we're at 0, we've now gone through 255 loops of 255. Return back to the main program. goto subloop return pulse_e: banksel LATA bsf LATA,5 ;sends one pulse on the E line nop ; waitaminit nop ; waitaminit bcf LATA,5 ;sets E line to low nop ; waitaminit nop ; waitaminit return end