read or write word vars


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2011
    Posts
    12

    Default read or write word vars

    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

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: read or write word vars

    What version of PBP do you have? Have you checked the manual?
    Code:
    myValue VAR WORD
    myValue = 1234
    WRITE 12, WORD myValue
    /Henrik.

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: read or write word vars

    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 ?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: read or write word vars

    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:
    Code:
    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.

Similar Threads

  1. Read write word and Hserin
    By aa222k in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st December 2011, 19:27
  2. I2C Write & Read
    By dallowgill in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th June 2011, 23:06
  3. PIC16F677 and READ/WRITE
    By LinkMTech in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th November 2010, 14:35
  4. I2c write&read
    By MINHLE in forum General
    Replies: 15
    Last Post: - 5th January 2010, 23:13
  5. I2C Read and Write
    By DerekMacom in forum mel PIC BASIC
    Replies: 14
    Last Post: - 21st April 2008, 15:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts