Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

question about store word variable in eeprom

Status
Not open for further replies.

mehran.rivandi

Newbie level 4
Joined
Mar 13, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
how can store a word variable in eeprom ?

i have a word array .

for example : m var word [10]

i want to store my array in eeprom .

and then read form eeprom .

it is very important for me .

please help me .

software : pic basic pro .
microprocessor : pic16f877a
 

mehran.rivandi

Newbie level 4
Joined
Mar 13, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
ok i work basic not c .

and then i want store just highbyte of word array in to the eeprom .
 

skogsjanne

Full Member level 3
Joined
May 28, 2009
Messages
172
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Activity points
2,084
I don't know BASIC but there is obviously some method to split words into bytes. Then you just store them the way you like.
 

mehran.rivandi

Newbie level 4
Joined
Mar 13, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
ok .

thanks .

this is my method to store word into the eeprom

Code:
    for  i = 1 to 10

            write   i          ,    m.LowByte[i]
            write   i+10     ,    m.HighByte[i]

        next i

and this is my method to read word from eeprom .

Code:
   for i = 1 to 10

           read   i          ,      m.LowByte[i]
           read   i+10     ,      m.HighByte[i]
     
     next i


this code is for pic basic pro software .

you think it is correct ?

---------- Post added at 22:44 ---------- Previous post was at 22:43 ----------

you think is it correct ?
 
Last edited by a moderator:

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,133
Helped
14,380
Reputation
29,024
Reaction score
13,134
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,211
If you look to the compiler manual, you'll notice, that word and long entities can be written with a single instruction.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,133
Helped
14,380
Reputation
29,024
Reaction score
13,134
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,211
Code:
WRITE Address,{WORD}{LONG}Value {,Value...}

Write byte, word or long (if PBPL used) Values to the on-chip EEPROM at the specified Address.
 

mehran.rivandi

Newbie level 4
Joined
Mar 13, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
excuse me can you write an example of my code ?

---------- Post added at 23:45 ---------- Previous post was at 23:28 ----------

THIS IS MY CODE
PHP:
'******************************************************************************************
' this program is for testing of read and write word array in to eeprom and display on lcd 
'******************************************************************************************

define LCD_DREG   PORTD
define LCD_DBIT   4
define LCD_RSREG  PORTD       
define LCD_RSBIT  2
define LCD_EREG   PORTD       
define LCD_EBIT   3
define LCD_BITS   4         
define LCD_LINES  2     


H var byte
L var byte

m var word [1] 
 
main:

m[0] = $4142   ' 41 = A   and  42 = B


write 1,m.highbyte [0] 
write 2,m.lowbyte [0] 


read 1,H 
read 2,L  

LCDOut $FE,1,H
Pause 2000


LCDOut $FE,1,L
Pause 2000


goto main
end
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,133
Helped
14,380
Reputation
29,024
Reaction score
13,134
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,211
Sorry, I'm not using BASIC since 20 years or so. The manual syntax is obvious in my view.

It implements, what most programmers would do in this case, storing a word in two consecutive memory cells. The memory addresses have to be incremented by two.

Something like
Code:
write 2*i, word m[i]
 

mehran.rivandi

Newbie level 4
Joined
Mar 13, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
THIS CODE WORKS CORRECTLY .

BUT I WANT YOUR CODE .
PHP:
WRITE Address,{WORD}{LONG}Value {,Value...}

Write byte, word or long (if PBPL used) Values to the on-chip EEPROM at the specified Address.


---------- Post added 15-03-12 at 00:05 ---------- Previous post was 14-03-12 at 23:51 ----------

OK THANKS YOUR CODE WORK CORRECTLY . I CHANGE MY CODE AND COMPILE IT AND IT WORKS CORRECTLY .
THIS IS a new code .
PHP:
'******************************************************************************************
' this program is for testing of read and write word array in to eeprom and display on lcd 
'******************************************************************************************

define LCD_DREG   PORTD
define LCD_DBIT   4
define LCD_RSREG  PORTD       
define LCD_RSBIT  2
define LCD_EREG   PORTD       
define LCD_EBIT   3
define LCD_BITS   4         
define LCD_LINES  2     


H var byte
L var byte
 I VAR BYTE
m var word [1] 
 
main:

m[0] = $4142   ' 41 = A   and  42 = B

 
write 1, WORD m[0]
 
read 1,L 
read 2,H  

LCDOut $FE,1,H
Pause 2000


LCDOut $FE,1,L
Pause 2000


goto main
end


---------- Post added at 00:10 ---------- Previous post was at 00:05 ----------

i think it is better
PHP:
'******************************************************************************************
' this program is for testing of read and write word array in to eeprom and display on lcd 
'******************************************************************************************

define LCD_DREG   PORTD
define LCD_DBIT   4
define LCD_RSREG  PORTD       
define LCD_RSBIT  2
define LCD_EREG   PORTD       
define LCD_EBIT   3
define LCD_BITS   4         
define LCD_LINES  2     


H var byte
L var byte
 I VAR BYTE
m var word [1] 
 
main:

m[0] = $4142   ' 41 = A   and  42 = B

for i = 0 to 10 
write (2*i)+1, WORD m[0]
next i 
      
read 1,L 
read 2,H  

LCDOut $FE,1,H
Pause 2000


LCDOut $FE,1,L
Pause 2000


goto main
end


---------- Post added at 00:11 ---------- Previous post was at 00:10 ----------

PHP:
for i = 0 to 10 
write (2*i)+1, WORD m[i]
next i
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top