PDA

View Full Version : read or write word vars



visitac
- 3rd November 2012, 18:47
Hello,

I need to save a word var that i receive trought serial communication on the pic eeprom
With byte vars i use like: write 12, $80
If i need to write to or read from the eeprom the value 1234 how must do it?

Thanks
Best regards
visitac

HenrikOlsson
- 3rd November 2012, 23:04
What version of PBP do you have? Have you checked the manual?

myValue VAR WORD
myValue = 1234
WRITE 12, WORD myValue

/Henrik.

longpole001
- 5th November 2012, 12:20
hendric , the var is written with the LSB first at the location , is there a way to make it the MSB first with the write command ?

HenrikOlsson
- 5th November 2012, 13:33
Why do you care? If you use READ to get the value back I'd be very surprised if it read in the wrong byte order.
Anyway, I don't know of any DEFINE or anything to change it so, if you really need reverse the byte order, I'd probably try something like:

Value VAR WORD
temp VAR WORD

Value = $1234 ' Some value

temp.lowByte = Value.HighByte
temp.highByte = Value.LowByte

' temp is now $3412

WRITE 0, WORD temp

/Henrik.