LM35 PIC18F452 BASIC LCD problem

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
 

Thread Starter

MSalah

Joined Dec 14, 2012
7
I tried editing the initialization, I heard this problem occurs because of wrong initialization but it still exists.
 

bertus

Joined Apr 5, 2008
22,278
Hello,

What kind of compiler are you using?
The , access would indicate the value of access to be loaded (IMO).

Bertus
 

Ian Rogers

Joined Dec 12, 2012
1,136
Da..Dahhh .. Proton basic... Now we can help.

Lcd defaults? If you have the LCD on any other pins you specify like this

Rich (BB code):
   LCD_DTPin = PORTB.4    
    LCD_RSPin = PORTB.3         
    LCD_ENPin = PORTB.2         
    LCD_Interface = 4            '4-bit Interface
    LCD_Lines = 2                 'in this case 2 lots of 2 lines
    LCD_Type = 0
 

JohnInTX

Joined Jun 26, 2012
4,787
"access"

Is it related to memory banks maybe?
Specifying ,ACCESS as part of the operand tells the assembler to use access i.e. non-banked RAM; when executing, the PIC will ignore BSR and use access RAM. I/O ports and other SFR are in upper access RAM and there is a varying amount in bank 0 for general use.

Specifying ,ACCESS is not necessary if all of your RAM addresses are completely specified i.e. 0xFF3. Some really old constructs only specified the lower byte since the bank had to be manually maintained using IRP:RP1:RP0 etc. and specifying ,ACCESS was a way to indicate banked/non-banked memory.

For fully specified RAM addresses, the assembler / compiler will generate the proper instruction automatically so you don't have to.
 
Top