PIC18F452 BASIC LCD problem

Discussion in 'Embedded Systems and Microcontrollers' started by MSalah, Dec 14, 2012.

Thread Status:
Not open for further replies.
  1. MSalah

    Thread Starter New Member

    Dec 14, 2012
    7
    0
    Hi,
    I used this code:
    Code ( (Unknown Language)):
    1.  
    2. Device 18F452
    3. XTAL 4
    4.  
    5.  
    6. ;LCD initialization
    7.  
    8. Declare LCD_DTPIN PORTB.4
    9. Declare LCD_ENPIN PORTB.3
    10. Declare LCD_INTERFACE 4
    11. Declare LCD_RSPIN PORTB.2
    12. Declare LCD_LINES 2
    13. Declare LCD_TYPE = 0
    14. cls
    15.  
    16. GoTo main
    17.  
    18. ASM
    19. main:
    20. ;port A
    21. clrf PORTA,access
    22. clrf PORTA,access
    23. setf TRISA,access
    24.  
    25. ;port C
    26. clrf PORTC,access
    27. clrf LATC,access
    28. clrf TRISC,access
    29. ;ADCON
    30. movlw 0x81
    31. movwf ADCON0,access
    32.  
    33. ;T0con
    34. movlw 0x07
    35. movwf T0CON,access
    36.  
    37.  
    38. again:
    39.  
    40. Call DELAY
    41. ;Start A/D
    42. bsf ADCON0,2,access
    43.  
    44. ;wait A/D
    45. loop:
    46. btfsc ADCON0,2,access
    47. bra loop
    48.  
    49. ;print temp
    50. GoTo LCD1
    51.  
    52. check:
    53. ;check upper limit
    54. movlw .138
    55. cpfslt ADRESH,access
    56. bra overheat
    57.  
    58. ;check middle limit
    59. movlw .103
    60. cpfslt ADRESH,access
    61. bra cooling ;high temp
    62.  
    63. ;check lower limit
    64. movlw .69
    65. cpfsgt ADRESH,access
    66. bra heating ;low temp
    67.  
    68. ;clear outputs 40-60
    69. clrf PORTC,access
    70. bra again
    71.  
    72. ;cooling >60
    73. cooling:
    74. bsf PORTC,2,access
    75. bcf PORTC,0,access
    76. bra again
    77.  
    78. ;heating <40
    79. heating:
    80. bsf PORTC,0,access
    81. bcf PORTC,2,access
    82. bra again
    83.  
    84. ;overheat >80
    85. overheat:
    86. bsf PORTC,2,access
    87. bsf PORTC,3,access
    88. GoTo LCD2
    89.  
    90. ;1s delay
    91. DELAY:
    92. clrf TMR0L,access
    93. clrf TMR0H,access
    94. bsf T0CON,7,access
    95. movlw 0x42
    96. wait2:
    97. cpfsgt TMR0L,access
    98. bra wait2
    99. movlw 0x0f
    100. cpfsgt TMR0H,access
    101. bra wait2
    102. bcf T0CON,7,access
    103. Return
    104.  
    105. ENDASM
    106.  
    107. LCD1:
    108. Cls
    109. Print At 1,1,"Temp=",Dec ADRESH *150/255
    110. DelayMS 500
    111. bra check
    112.  
    113. LCD2:
    114. Cls
    115. Print At 1,1, "Temp=", Dec ADRESH *150/255
    116. Print At 2,2,"OVERHEATING!!"
    117. DelayMS 3000
    118. bra again
    119.  
    everything works fine but not the LCD, it displays full blocks on the 1st line only, and not the conditions I wrote in the code

    any help would be appreciated :D
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Last edited by a moderator: Dec 15, 2012
Loading...
Thread Status:
Not open for further replies.