PIC18F452 BASIC LCD problem

Status
Not open for further replies.

Thread Starter

MSalah

Joined Dec 14, 2012
7
Hi,
I used this code:
Rich (BB code):
Device 18F452
XTAL 4


;LCD initialization

Declare LCD_DTPIN PORTB.4
Declare LCD_ENPIN PORTB.3
Declare LCD_INTERFACE 4
Declare LCD_RSPIN PORTB.2
Declare LCD_LINES 2
Declare LCD_TYPE = 0
cls

GoTo main

ASM 
main:
;port A
clrf PORTA,access
clrf PORTA,access
setf TRISA,access

;port C
clrf PORTC,access
clrf LATC,access
clrf TRISC,access
;ADCON
movlw 0x81
movwf ADCON0,access

;T0con 
movlw 0x07
movwf T0CON,access


again:

Call DELAY
;Start A/D
bsf ADCON0,2,access

;wait A/D
loop: 
btfsc ADCON0,2,access
bra loop

;print temp 
GoTo LCD1 

check:
;check upper limit
movlw .138
cpfslt ADRESH,access
bra overheat

;check middle limit
movlw .103 
cpfslt ADRESH,access
bra cooling ;high temp

;check lower limit
movlw .69
cpfsgt ADRESH,access
bra heating ;low temp

;clear outputs 40-60 
clrf PORTC,access
bra again

;cooling >60
cooling:
bsf PORTC,2,access
bcf PORTC,0,access
bra again

;heating <40
heating:
bsf PORTC,0,access
bcf PORTC,2,access
bra again

;overheat >80
overheat:
bsf PORTC,2,access
bsf PORTC,3,access
GoTo LCD2

;1s delay
DELAY:
clrf TMR0L,access
clrf TMR0H,access 
bsf T0CON,7,access
movlw 0x42
wait2:
cpfsgt TMR0L,access
bra wait2
movlw 0x0f
cpfsgt TMR0H,access
bra wait2
bcf T0CON,7,access
Return

ENDASM

LCD1:
Cls
Print At 1,1,"Temp=",Dec ADRESH *150/255
DelayMS 500
bra check

LCD2:
Cls
Print At 1,1, "Temp=", Dec ADRESH *150/255
Print At 2,2,"OVERHEATING!!"
DelayMS 3000
bra again
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
 
Status
Not open for further replies.
Top