1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Pic18f4550 adc

Discussion in 'Microcontrollers' started by adrianvon, Jan 11, 2012.

  1. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Thanks for your reply Ian Rogers.

    What is your opinion about the saved settings mentioned in post number 116 ? is it ok to save them in registers?
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    Yes of course it is... You could save them in EEPROM so they are saved on power cycles.

    you have oodles of ram registers to play with...
     
  3. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    OK thanks.

    Yes, that's the next thing to learn ;)
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2

    Hi,

    At the moment i am using the coding below for the LCD:

    Code (text):
        COUNT1        EQU 60H
        COUNT2        EQU 61H
        COUNT3        EQU 62H
        TABLE_TEMP    EQU 63H
        TABLE         EQU 64H


     
        ORG 0000H


        ;INITIALIZATION
     
        MOVLW 0FH           ;INITIALIZE ALL PORTS AS DIGITAL INPUTS
        MOVWF ADCON1
     
        MOVLW 07H           ;CONFIGURE COMPARATORS FOR DIGITAL INPUTS
        MOVWF CMCON
     
        CLRF TRISB
        CLRF PORTB
     
        MOVLW B'00000000'   ;PORTD IS CONFIGURED AS OUTPUTS
        MOVWF TRISD
        CLRF LATD
        CLRF PORTD
     





    MAIN
     
        CALL LONG_DELAY      ;DELAY USED AT START-UP TILL SUPPLY REACHES FULL VOLTAGE
     
    FUNCTION_SET
     
        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
     
        MOVLW B'00111100'    ;SET LCD TO 8 BIT INTERFACE, SET TO 4 LINE MODE, 5x7 DOT FORMAT.  (SEE 'CONTROL CODES TABLE' IN LCD DATASHEET FOR REFERENCE)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     
    DISPLAY_ON

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'00001100'    ;TURN DISPLAY ON, CURSOR UNDERLINE OFF, CERSOR BLINK OFF.   (SEE 'CONTROL CODES TABLE' IN LCD DATASHEET FOR REFERENCE)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY


        MOVLW B'10000011'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     
        CLRF TABLE           ;CLEAR THE TABLE REGISTER TO BE ON THE SAFE SIDE
     

    MESSAGE

        MOVF TABLE,W        ;MOVE THE VALUE OF Wreg TO TABLE. THIS IS DONE TO INCREMENT THE POINTER
        CALL TEXT           ;CALL TEXT ROUTINE
        ANDLW 0FFH          ; Check for NULL
        BTFSC STATUS,2      ;ARE ALL CHARACTERS DISPLAYED...
       ;GOTO SEND           ;...IF YES, GO TO THIS LABEL WHEN THE CHARACTERS ARE ALL DISPLAYED
        GOTO DISPLAY_VALUE  ;USE THIS INSTRUCTION IF A VALUE NEEDS TO BE DISPLAYED. IF NOT, REMOVE THIS INSTRUCTION AND USE THE ONE ABOVE (I.E. GOTO SEND)
        BSF PORTB,5         ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6         ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        MOVWF PORTD         ;MOVE THE CHARACTER TO THE LCD
        CALL PULSE_E        ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY    ;SMALL DELAY WHILE LCD IS BUSY
        INCF TABLE,F        ;INCREMENT THE TABLE REGISTER TO MOVE TO NEXT CHARACTER
        GOTO MESSAGE        ;GO BACK TO MASSAGE LABLE TO DISPLAY NEXT CHARACTER
     
     
    TEXT

        MOVWF TABLE_TEMP   ;MOVE THE VALUE OF Wreg TO TABLE_TEMP REGISTER
        BCF STATUS,0      
        RLCF TABLE_TEMP,F              
        MOVLW HIGH(mess)    ; Get High address
        BTFSC STATUS,0  ; If > 255             
        INCF WREG,W    
        MOVWF PCLATH
        MOVLW LOW(mess)  ; Get low address         
        ADDWF TABLE_TEMP,W  ; add message pointer
        BTFSC STATUS,0  ; if > 255         
        INCF PCLATH,F
        MOVWF PCL

                   
    mess

       
        RETLW 'T'
        RETLW 'e'
        RETLW 's'
        RETLW 't'
        RETLW 0H


    DISPLAY_VALUE

        MOVFF VALUE,PORTD     ;MOVE THE VALUE OF REGISER 'VALUE' TO THE DATA PORT (PORTD)
        CALL SMALL_DELAY      ;SMALL DELAY WHILE LCD IS BUSY
        CALL PULSE_E          ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY      ;SMALL DELAY WHILE LCD IS BUSY
        GOTO SEND             ;GO TO THIS LABEL WHEN FINISHED
     
    PULSE_E

        BSF PORTB,7
        NOP
        BCF PORTB,7
        RETURN
     
     
     
    LONG_DELAY

        MOVLW   .2
        MOVWF   COUNT1
        MOVLW   .69
        MOVWF   COUNT2
        MOVLW   .169
        MOVWF   COUNT3
    loop       
        DECFSZ  COUNT3
        GOTO    loop
        DECFSZ  COUNT2
        GOTO    loop
        DECFSZ  COUNT1
        GOTO    loop
        RETURN
     
     
     
    SMALL_DELAY

        MOVLW .10
        MOVWF COUNT2
    LABEL2
        CLRF COUNT1
    LABEL1
        DECFSZ COUNT1
        GOTO LABEL1
        DECFSZ COUNT2
        GOTO LABEL2
        RETURN
     
    SEND
     
    GOTO $      ; THIS WILL STOP THE MICRO FROM STARTING TO EXECUTRE THE PROGRAME AGAIN EVEN AFTER
                ; SENDING IT TO THE END DIRECTIVE
     
    END
    Is there a way to eliminate the TEXT routine and do if similar to the coding in the file attached (experiment 8) ??
     

    Attached Files:

    • lcd2.pdf
      File size:
      121.5 KB
      Views:
      89
    Last edited: Feb 12, 2012
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    Read the post from mikebits on this forum..I linked it in post #90.... This is the best way to print strings / text... It uses a macro..
     
  7. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi,

    I cannot understand the coding of that forum, but now i did another setup (coding below) which is much easier for me to understand. Is it structured correctly?? I think by far this is the best setup that i can find since much of the coding is done once and then all you have to write is " MOVLW 'C' .... CALL SEND_CHAR".

    Code (text):
        COUNT1        EQU 60H
        COUNT2        EQU 61H
        COUNT3        EQU 62H
        TEMP_CHAR     EQU 63H
       


     
        ORG 0000H


        ;INITIALIZATION
     
        MOVLW 0FH           ;INITIALIZE ALL PORTS AS DIGITAL INPUTS
        MOVWF ADCON1
     
        MOVLW 07H           ;CONFIGURE COMPARATORS FOR DIGITAL INPUTS
        MOVWF CMCON
     
        CLRF TRISB
        CLRF PORTB
     
        MOVLW B'00000000'   ;PORTD IS CONFIGURED AS OUTPUTS
        MOVWF TRISD
        CLRF LATD
        CLRF PORTD
     



    MAIN
     
        CALL LONG_DELAY      ;DELAY USED AT START-UP TILL SUPPLY REACHES FULL VOLTAGE
     

    ;FUNCTION SET
     
        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
     
        MOVLW B'00111100'    ;SET LCD TO 8 BIT INTERFACE, SET TO 4 LINE MODE, 5x7 DOT FORMAT.  (SEE 'CONTROL CODES TABLE' IN LCD DATASHEET FOR REFERENCE)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     
    ;DISPLAY ON

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'00001100'    ;TURN DISPLAY ON, CURSOR UNDERLINE OFF, CERSOR BLINK OFF.   (SEE 'CONTROL CODES TABLE' IN LCD DATASHEET FOR REFERENCE)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY


    ;LCD LOCATION

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11010011'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY





     
        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW 'A'
        CALL SEND_CHAR

        MOVLW 'B'
        CALL SEND_CHAR

        MOVLW 'C'
        CALL SEND_CHAR

        MOVLW 'D'
        CALL SEND_CHAR

        MOVLW 'E'
        CALL SEND_CHAR

        MOVLW 'F'
        CALL SEND_CHAR

        MOVLW 'G'
        CALL SEND_CHAR

        MOVLW 'H'
        CALL SEND_CHAR

        MOVLW 'I'
        CALL SEND_CHAR

        MOVLW 'J'
        CALL SEND_CHAR

        MOVLW 'K'
        CALL SEND_CHAR

        MOVLW 'L'
        CALL SEND_CHAR

    LINEEE
    BRA LINEEE
       





    SEND_CHAR

        MOVWF TEMP_CHAR
        MOVFF TEMP_CHAR,PORTD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

    RETURN


    CLEAR_LCD

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'000000001'    ;TURN DISPLAY ON, CURSOR UNDERLINE OFF, CERSOR BLINK OFF.   (SEE 'CONTROL CODES TABLE' IN LCD DATASHEET FOR REFERENCE)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

    RETURN


    PULSE_E

        BSF PORTB,7
        NOP
        BCF PORTB,7
        RETURN
     
     
     
    LONG_DELAY

        MOVLW   .2
        MOVWF   COUNT1
        MOVLW   .69
        MOVWF   COUNT2
        MOVLW   .169
        MOVWF   COUNT3
    loop       
        DECFSZ  COUNT3
        GOTO    loop
        DECFSZ  COUNT2
        GOTO    loop
        DECFSZ  COUNT1
        GOTO    loop
        RETURN
     
     
     
    SMALL_DELAY

        MOVLW .10
        MOVWF COUNT2
    LABEL2
        CLRF COUNT1
    LABEL1
        DECFSZ COUNT1
        GOTO LABEL1
        DECFSZ COUNT2
        GOTO LABEL2
        RETURN
     
    SEND
     
    GOTO $      ; THIS WILL STOP THE MICRO FROM STARTING TO EXECUTRE THE PROGRAME AGAIN EVEN AFTER
                ; SENDING IT TO THE END DIRECTIVE
     
    END
     
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    You can do it that way.... As your program expands, and your knowledge increases.. You will be looking for more efficient string routines.

    But! You can do it however you like..... Printing the decimal is next..Did you get your head around the bin2bcd routine in the code I sent you?
     
  9. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Yes, that's the binary to ASCII routine right?

    Below is a video of the LCD displaying the temperature :)

    http://youtu.be/RBWVazZhzP8

    BTW, can i use a call instruction in a call routine?
     
    Last edited: Feb 12, 2012
  10. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    Like I said earlier in this thread... A pic18 series of processor can have up to 16 nested calls... A nested call is when you call..say.. writelcd then writelcd calls pusleE.

    an example

    main code loop

    call function 1 /// address has to be remembered to return back here (stack increased )

    end main

    function 1

    call function 2 /// address has to be remembered here as well (stack increased)

    end function 1

    so on and so on.

    There are 16 possible stack positions, so in theory 16 nested calls......HOWEVER.. If you use interrupts, an interrupt needs two stack positions, so in reality only 14 nested calls can be made.
     
    • Like Like x 1
  11. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Thanks for explaining :)
     
  12. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi,

    How can i display the highlighted character in the attached pic? and is it possible to clear a single row from the LCD instead of clearing all rows?
     
  13. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    You just send the character code.. In this case "0x10"

    I write a routine to display 16 blank characters " " this clears a space...
     
  14. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi,

    Nothing is being displayed when i write b'00010000'.
    Can it be that i have to change the ROM address since that character is in ROM code A02.

    Attached is the datasheet.

    Thanks
     
  15. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    That LCD hasn't got them characters..... You can make them though.... you need to write to DDram, The datasheet points you in the right direction... the first 8 characters are yours to control. You need to send all the bytes to the ddram (there are 64 of them).. the first 3 bits are lost so define the chars to the left..
     
    Last edited: Feb 14, 2012
  16. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi,

    Thanks for your reply.

    At the moment i am trying to program the menu arrow (pointer), but im finding difficulties. For some reason it is not working. Does anyone knows what is wrong with the coding please?
    Code (text):

    LINE6_LCD_MENU

    BTFSC PORTB,1                       ;CHECK DOWN SW
    GOTO DOWN_MENU_ARROW  ;IF PRESSED, MOVE ARROW DOWN AND INCREMENT THE MENU_ARROW REGISTER
    BTFSC PORTB,2                       ;CHECK UP SW
    GOTO UP_MENU_ARROW        ;IF PRESSED, MOVE ARROW UP AND DECREMENT THE MENU_ARROW REGISTER
    BRA LINE6_LCD_MENU           ;IF NONE OF THE SWITCHES IS PRESSED, GO TO LINE6_LCD_MENU






    DOWN_MENU_ARROW              ;MOVE ARROW DOWN

    INCF MENU_ARROW                 ;INCREMENT THE MENU_ARROW REGISTER TO INDICATE THE LOCATION OF THE ARROW

    MOVLW MENU_ARROW            ;MOVE THE VALUE TO THE WORKING REG
    SUBLW .3                                ;SUB BY 3
    BTFSS STATUS,Z                      ;SKIP IF RESULT NOT = 0
    CALL LCD_ARROW_1              ;IF EQUAL TO 0, DISPLAY ARROW IN ROW 1

    MOVLW MENU_ARROW
    SUBLW .2
    BTFSS STATUS,Z
    CALL LCD_ARROW_3

    MOVLW MENU_ARROW
    SUBLW .1
    BTFSS STATUS,Z
    CALL LCD_ARROW_2
     
  17. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi, can someone help me with the coding below please.

    In the coding i am putting a value (in this case 1 decimal) in reg1 and then the program should go to different call routines according to the value in reg1.

    For instance if the value in reg1 is 2, when subtracted be 2, the program is suppose to go to the LCD_ARROW_2 call routine.

    Code (text):

    MOVLW .1                                    
    MOVWF REG1


    MOVLW REG1
    SUBLW .3
    BTFSS STATUS,Z
    CALL LCD_ARROW_3

    MOVLW REG1
    SUBLW .2
    BTFSS STATUS,Z
    CALL LCD_ARROW_2

    MOVLW REG1
    SUBLW .1
    BTFSS STATUS,Z
    CALL LCD_ARROW_1
     
  18. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    BitTestFileSkipifSet

    If you need to call arrow 2 only when REG1 is 2 you'll need to BTFSC

    Sorry.. Defined.... the zero flag is set if the w reg is 0.
     
    Last edited: Feb 15, 2012
  19. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi, when i use skip if clear instruction, noting is being displayed.
     
  20. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    What is displayed when REG1 = 1?

    Can I see the arrow routine?
     
  21. adrianvon

    adrianvon Member

    Joined:
    Jan 22, 2011
    Messages:
    322
    Likes:
    2
    Hi,

    When REG1 = 1 the program should go to the LCD_ARROW_1 routine.

    The arrow routine is the one below:

    Code (text):
    ;DISPLAY FIRST ARROW

    LCD_ARROW_1

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11000000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW '>'
        CALL SEND_CHAR

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'10010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR


        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR


    RETURN




    ;DISPLAY SECOND ARROW

    LCD_ARROW_2

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11000000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'10010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW '>'
        CALL SEND_CHAR


        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR

    RETURN



    ;DISPLAY THIRD ARROW

    LCD_ARROW_3

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11000000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR

        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'10010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW ' '
        CALL SEND_CHAR


        BCF PORTB,5          ;R/S SET TO LOW TO INDICATE THAT DATA BELOW IS A COMMAND
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY
        MOVLW B'11010000'    ;SET THE LOCATION OF THE CHARACTERS. "0x80"= line1, "0xC0"= line2,  "0x90"= line3,  "0xD0"= line4. To set column increase the value (ex."0x82"= line1 column 2)
        MOVWF PORTD          ;SEND THE ABOVE COMAND TO THE LCD
        CALL PULSE_E         ;PULSE THE E PIN TO ENABLE COMMAND TO ENTER LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

     

        BSF PORTB,5          ;R/S IS SET TO DATA TRANSFER
        BCF PORTB,6          ;R/W SET TO LOW TO INDICATE THAT WRITE COMMAND TO LCD
        CALL SMALL_DELAY     ;SMALL DELAY WHILE LCD IS BUSY

        MOVLW '>'
        CALL SEND_CHAR


    RETURN

     
     

Share This Page