1 Attachment(s)
cant get my Lcd to work using Pic18f452
i am new to this so please help me out in anyway. I trying to get my code to work and so far i am getting just black boxes on the lcd display..
i also get this error when compileing "config has been deprecated for 18f devices
define LCD_DREG PORTB ' set LCD Data port
'
define LCD_DBIT 4 ' set starting data bit
'
define LCD_RSREG PORTB ' set LCD registers
'
define LCD_RSBIT 2 ' set LCD register select bit
'
define LCD_EREG PORTB ' set LCD enable port
'
define LCD_EBIT 3 ' set LCD enable bit
'
DEFINE LCD_BITS 4 ' set LCD bus size
'
define LCD_LINES 4 ' set number of lines on LCD
'
define LCD_COMMANDUS 2000 ' set command delay time in us
'
define LCD_DATAUS 50 ' set data delay time in us
'''''''''''''''''
'''Variables'''
v1 var word 'Variable where digital value will be stored
'''''''''''''''
'''TRIS registers'''
trisb = %00000000 'Set PORTB pins as outputs
''''''''''''''''''''
' This 'INCLUDE' routine is use to read a matrix keypad.
' Allow to use various keypad format
' Allow to place the keypad ROW and COL on different PORT.
' The routine set TRIS register for you
' How to use it
' =============
' 1. Include the file
' write
' INCLUDE "KeyPad.bas"
' somewhere in your code.. after TRIS setting and before MAIN loop
'
' 2. Call the Keypad routine by one or the other method bellow
' 1. By calling the macro
' @ READKEYPAD _YourVar
' result store in 'YourVar' wich must be defined as a BYTE sized variable
'
' 2. By using GOSUB
' GOSUB KeypadScan
' result is store in 'Key' Variable
' Specific DEFINE
' ===============
' The defaults setings are
' 1. Keypad ROW are connected to PORTB<3:0>
' 2. Keypad COL are connected to PORTB<7:4>
' 3. Debounce delay = 200 mSec
' 4. No auto-repeat
' 5. Keypad type 4X4
'
' If you decide to change default settings, here's the DEFINEs list
' DEFINE KEYPAD_ROW 4 ' 4 ROW keypad
' DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB
' DEFINE KEYPAD_ROW_BIT 4 ' ROW0 = PORTB.4
' DEFINE KEYPAD_COL 4 ' 4 COL keypad
' DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
' DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0
' DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec
' DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature
'
' When using the auto-repeat feature, the delay is the debounce delay (DEBOUNCEMS)
' Hardware Connection
' ===================
' 1. Column bits must have Pull-up resistor attach to VCC
' 2. ROW bits must be connected in serie with resistor.
' Results
' =======
' Results are always set the same way, even with different keypad type
'
' 3X4
' ---
' Col0 Col1 Col2 Col3
' ---- ---- ---- ----
' 1 2 3 4 Row0
' 5 6 7 8 Row1
' 9 10 11 12 Row2
'
' 6X5
' ---
' Col0 Col1 Col2 Col3 Col4
' ---- ---- ---- ---- ----
' 1 2 3 4 5 Row0
' 6 7 8 9 10 Row1
' 11 12 13 14 15 Row2
' 16 17 18 19 20 Row3
' 21 22 23 24 25 Row4
' 26 27 28 29 30 Row5
'
asm
errorlevel 0,-207 ; Disable 'found opcode after...' warning
;
; Macro Definition
; ================
READKEYPAD macro KeyVar
L?CALL _KeypadScan
MOVE?BB _Key,KeyVar
endm
;
; Default settings
; ================
KB_ROW = 4 ; 4 ROW keypad
KB_ROW_PORT = PORTC ; Keypad ROW on PORTC
KB_ROW_BIT = 0 ; ROW0 = PORTB.0
KB_COL = 4 ; 4 COL keypad
KB_COL_PORT = PORTC ; Keypad Col on PORTC
KB_COL_BIT = 4 ; COL0 = PORTB.4
DebounceDelay = d'200' ; debounce delay 200mSec
;
; Software Definition
; ===================
;
; Keypad type definition
; ----------------------
ifdef KEYPAD_ROW
KB_ROW = KEYPAD_ROW ; Assign amount of ROW
endif
ifdef KEYPAD_COL
KB_COL = KEYPAD_COL ; Assign amount of COL
endif
;
; ROW pins assignement
; --------------------
ifdef KEYPAD_ROW_PORT
KB_ROW_PORT = KEYPAD_ROW_PORT ; Assign ROW to user selected PORT
endif
ifdef KEYPAD_ROW_BIT
KB_ROW_BIT = KEYPAD_ROW_BIT ; Assign ROW0 to user selected BIT
endif
;
; COLUMN pins assignement
; -----------------------
ifdef KEYPAD_COL_PORT
KB_COL_PORT = KEYPAD_COL_PORT ; Assign COL to user selected PORT
endif
ifdef KEYPAD_COL_BIT
KB_COL_BIT = KEYPAD_COL_BIT ; Assign COL0 to user selected BIT
endif
;
; Keypad debounce delay
; ---------------------
ifdef KEYPAD_DEBOUNCEMS
DebounceDelay=KEYPAD_DEBOUNCEMS
endif
endasm
'
' Variable definition
' ===================
KB_ROW_PORT VAR BYTE EXT ' ROW port
KB_COL_PORT VAR BYTE EXT ' COL port
Col var byte '
Row var byte '
RowBit var byte '
Key var byte ' result of scanned key
KeyTemp var byte '
'
' Constant definition
' ===================
KeyMask con EXT ' Key mask when reading PORT
InitialState con EXT ' initial ROW PORT value
KB_ROW CON EXT ' # row
KB_COL CON EXT ' # column
KB_ROW_BIT CON EXT ' ROW0 bit
KB_COL_BIT CON EXT ' COL0 bit
DebounceDelay CON EXT ' Debounce delay, also Auto-Repeat delay if defined
asm
KeyMask = b'11111111' >> (8-KB_COL) ; use to keep only COL bits
InitialState=b'00001111' << KB_ROW_BIT ; Initial state of ROW column bits
endasm
start:
Pause 1500
lcdout $fe, 1 ' clear display
lcdout $fe, $80 ' move cursor to begining of line
lcdout " Welcome to JDA Tech "
lcdout $fe, $C0
Lcdout " Wireless Sleep Apnea " ' output the following
lcdout $fe, $94
LCDout " Monitor"
pause 3000
'
Main: ' Operations todo
'
Lcdout $fe, 1
lcdout $fe, $80
lcdout " Choose an Option"
pause 3000
lcdout $fe,1
'
lcdout $fe, $80
lcdout "1 :Start to Record"
lcdout $fe, $C0
lcdout "2 :Stop " ' display on LCD
pause 10000
'
lcdout $fe, 1
lcdout $fe, $80
lcdout "3: Send Data to RS-232"
lcdout $fe, $C0
Lcdout "4: Last Reading Percentage"
gosub Keypadscan
If (key = 1) then
pause 100
lcdout $fe, $D4, #key
Goto Record
endif
IF (key = 2) then
Pause 100
lcdout $fe, $D4, #key
Stop
Endif
IF ( key = 3 ) Then
Pause 100
lcdout $fe, $D4, #key
GOTO Send
endif
If ( key = 5 ) then
Pause 100
lcdout $fe, $D4, #key
Goto Percentage
endif
IF ( key > 5 ) then
pause 100
lcdout $fe, $C0
Lcdout "Invalid Choice"
GOTO main
ENDIF
still having the same issues
im still trying to get the lcd to work.. i dont know how to configure the lpv to disable and i looked at the contrast and it was fine since i used someones else program using the same pic that im using which is the pic18f452 and it came out working just fine. Im up for anymore ideas or anwsers to solve the problem at hand