Hi srig,
Actualy you don't need to know at wich address you write to internal EEPROM, PBP handle it.
You must define OSC 20... always
The following will write and read on internal EEPROM. And display on LCD.
Code:
' Code to Read/Write to Internal EEPROM
' =====================================
'
' File name : InternalEEPROM.bas
' Company : Mister E
' Programmer : Steve Monfette
' Date : 22-12-2004
' Device : PIC18f452-I/P
'
'
'
' Device programming mode and hardware definition
' ===============================================
'
'
'
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
' Oscillator switch OFF
' Use HS oscillator (20MHZ here)
'
@ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
' Brown out reset ON @ 4.5Volts
' Power-up timer ON
'
@ __CONFIG _CONFIG2H, _WDT_ON_2H
' Watch dog timer ON
'
@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
' Stack over/underflow ON
' Low Voltage programming OFF
' Background debugger OFF
'
define OSC 20 'Use of 20 MHZ crystal
' Lcd defines
' ===========
' BO-B3 : Data port (pin 33-36)
' B4 : Rs Bit (pin 37)
' B5 : E Bit (pin 38)
'
'
'
define LCD_DREG PORTB ' Set data pin of LCD to
define LCD_DBIT 0 ' PORTB.0-PORTB.3
define LCD_RSREG PORTB ' Set RS bit of LCD to
define LCD_RSBIT 4 ' PORTB.4
define LCD_EREG PORTB ' Set E bit of LCD to
define LCD_EBIT 5 ' PORTB.5
DEFINE LCD_LINES 4 ' 4 Lines LCD
define LCD_COMMANDUS 2000 ' Command delay time in uSec
DEFINE LCD_DATAUS 50 ' Data delay time in uSec
'
'
'
' Variable definition
' ===================
'
'
'
Addr var Byte
ToStore var byte
ToRead var byte
'
'
' Let's begin
' ===========
'
PAUSE 500 ' waiting for LCD Start up
' Writing to internal EEPROM
' ==========================
'
For addr=0 to 10
Tostore = 10+addr
write Addr, tostore
next
'
' Reading from internal EEPROM
' ============================
'
For addr=0 to 10
read addr,Toread
lcdout $FE,1,"Address : ",dec addr,_
$FE,$C0,"Data : ",dec ToRead
Pause 1000 ' wait 1 sec between each display
next
Here:goto here
Bookmarks