Hello
Can the DATA command handle word variable?
like this
Data @1, $1DF4, $FAFD, $AB13, $3FC3
For i = 1 to 4
read i,wordvar
'do anything
next i
Is this correct?
Thanks
Best Regards
Pedro
Printable View
Hello
Can the DATA command handle word variable?
like this
Data @1, $1DF4, $FAFD, $AB13, $3FC3
For i = 1 to 4
read i,wordvar
'do anything
next i
Is this correct?
Thanks
Best Regards
Pedro
Data @0, $1DF4, $FAFD, $AB13, $3FC3
For i = 0 to 3
read i , wordvar.lowbyte
read i , workvar.highbyte
'do anything
next i
1st time thru wordvar = $1DF4
2nd time thru wordvar = $FAFD
3rd time thru wordvar = $AB13
4th time thru wordvar = $3FC3
It's all right there in your handy PicBasicPro manual that you got when you bought PicBasicPro, page 53 and page 123.
Mine's green, what color is yours?
Mine's Olive.Quote:
Mine's green, what color is yours?
And yup, right there on page 53 is all about the DATA statement.
And in it, it says ...
"Only the least significant byte of numeric values are stored unless the WORD modifier is used"
Therefore:
Data @1, WORD $1DF4, WORD $FAFD, WORD $AB13, WORD $3FC3
Regards,
Hello Darrel
data @1, word $E276, word $E183, word $8001, word $EF90
and how can i read the variavle?
so?
for i = 1 to 4
read i, wordvar
''do anything
next i
is that correct?
Thanks
Regards
Pedro
Well, like everthing else, there's probably 100 different ways to go about it. And the best way depends on how your program needs to use it.
But the biggest thing to remember is that you can only READ 1 byte at a time. So, to read a WORD value must be done in 2 operations.
If you wanted to read the data into an array of WORDS, you could do this...Code:READ 1, wordvar.LowByte
READ 2, wordvar.HighByte
If you just want to read individual words, then you'll need to know where they are located in EEPROM. You could just count bytes in the data and use the starting address as the location for the READ. But as the program changes, the data might change too, and all those locations you counted fly out the window.Code:ArraySize CON 4
WordArray VAR WORD[ArraySize]
Ptr VAR BYTE
DataStart VAR BYTE
DataStart = 1
For Ptr = 0 to (ArraySize * 2) -1
READ DataStart + Ptr, WordArray.LowByte(Ptr)
Next Ptr
So the easiest way to deal with individual Locations is to give them names in the DATA statement. Then when things change, the pointers to the data change too.
Well, that's 3 possibles, at least 97 more available. :)Code:Calibration DATA @1, WORD $1DF4
Offset DATA WORD $FAFD
Something DATA WORD $AB13
Another DATA WORD $3FC3
READ Something, wordvar.LowByte
READ Something + 1, wordvar.HighByte
; returns $AB13
READ Calibration, wordvar.LowByte
READ Calibration + 1, wordvar.HighByte
; returns $1DF4
HTH,
Thank's Darrel for your help
Regards
Pedro
Oh Yeah, forgot to mention that you might find this usefull as well.
EEPROM Variables (EE_Vars.pbp)
http://www.picbasic.co.uk/forum/showthread.php?t=2444
<br>
Could you get someone to take a picture of that?
Just thought it might Brighten somebody's Day. :D
<br>