serially sending data and displaying on lcd but showing garbage data

Discussion in 'Embedded Systems and Microcontrollers' started by yousufsaleem, May 3, 2013.

  1. yousufsaleem

    Thread Starter New Member

    Sep 28, 2011
    16
    0
    hi
    i am using pic18f452 for interfacing serially with my computer and wanted to display that data on lcd conned to my controller

    following is my code

    Code ( (Unknown Language)):
    1.  
    2. #INCLUDE P18F452.INC
    3.  
    4. LCD_DATA    EQU PORTD  
    5. LCD_CTRL    EQU PORTB  
    6. RS  EQU RB0
    7. RW  EQU RB1
    8. EN  EQU RB2
    9. R2  EQU 0x2
    10. R3  EQU 0x3
    11. R4  EQU 0x4
    12. R5  EQU 0x5
    13. R6  EQU 0x6
    14. R7  EQU 0x7
    15. ORG 00H
    16. MOVLW   B'10010000'
    17. MOVWF RCSTA
    18. MOVLW D'15'
    19. MOVWF SPBRG
    20. BSF TRISC, RX
    21. CLRF TRISD 
    22. CLRF    TRISB  
    23. BCF LCD_CTRL,EN
    24. CALL LDELAY
    25. MOVLW 0x38 
    26. CALL    COMMAND
    27. CALL    LDELAY
    28. MOVLW   0x0E
    29. CALL    COMMAND
    30. CALL    READY
    31. MOVLW   0x01
    32. CALL    COMMAND
    33. CALL    READY
    34. MOVLW   0x80
    35. R1  BTFSS   PIR1, RCIF
    36. BRA R1
    37. MOVF    RCREG, w   
    38. CALL    DATA_DISPLAY
    39. CALL    READY
    40. BRA R1
    41. HERE    BRA HERE
    42. COMMAND MOVWF   LCD_DATA
    43. BCF LCD_CTRL,RS
    44. BCF LCD_CTRL,RW
    45. BSF LCD_CTRL,EN
    46. CALL    SDELAY 
    47. BCF LCD_CTRL,EN
    48. RETURN
    49. DATA_DISPLAY MOVWF LCD_DATA
    50. BSF LCD_CTRL,RS
    51. BCF LCD_CTRL,RW
    52. BSF LCD_CTRL,EN
    53. CALL    SDELAY 
    54. BCF LCD_CTRL,EN
    55. RETURN
    56. READY   SETF    TRISD  
    57. BCF LCD_CTRL,RS
    58. BSF LCD_CTRL,RW
    59. BACK    BSF LCD_CTRL,EN
    60. CALL    SDELAY 
    61. BCF LCD_CTRL,EN
    62. BTFSC LCD_DATA,7
    63. BRA BACK
    64. CLRF    TRISD  
    65. LDELAY
    66. MOVLW    D'10' 
    67. MOVWF    R4
    68. BACK2    MOVLW   D'25' 
    69. MOVWF    R3
    70. AGAIN5   MOVLW   D'20' 
    71. MOVWF    R2
    72. HERE1    NOP
    73. NOP
    74. DECF     R2, F 
    75. BNZ  HERE1 
    76. DECF     R3, F 
    77. BNZ  AGAIN5
    78. DECF     R4, F 
    79. BNZ  BACK2
    80. RETURN
    81.  
    82. SDELAY
    83. MOVLW    D'2'  
    84. MOVWF    R5
    85. BACK1    MOVLW   D'10' 
    86. MOVWF    R6
    87. AGAIN1   MOVLW   D'25' 
    88. MOVWF    R7
    89. HERE2    NOP
    90. NOP
    91. DECF     R7, F 
    92. BNZ  HERE2 
    93. DECF     R6, F 
    94. BNZ  AGAIN1
    95. DECF     R5, F 
    96. BNZ  BACK1
    97.  
    98.  
    99. RETURN
    100.  
    101.  
    102. END
    103.  
     
    Last edited by a moderator: May 4, 2013
  2. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    Sounds like either serial baud rate problems or data line wiring issues on the LCD.....

    too bad your attachment is on another forum, so can not be viewed unless you are a member of edaboard..... not going to join just to help you, you should post all matters relating to this subject on THIS forum.
     
  3. yousufsaleem

    Thread Starter New Member

    Sep 28, 2011
    16
    0
    bro its giving garbage result even after correction of baud rate
     
  4. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    Did you check the lcd wiring? Just to make sure alll control and data lines are connected properly?
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,016
    Can you display anything ohn the LCD? Just straight text? For example can you display "hello"?

    You should start there.
     
Loading...