Stumped with word variable


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,641


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    yes its hard to remember wether the data statement saves words as highbyte first or not
    and then does the write word do the same ?, to read them back properly you must get it right.
    but write 1 ,word wordvar and read 1, wordvar is the way to go if you can't be bothered understanding what happens

    data @1 ,1,2 ; (wordvar.highbyte),( wordvar.lowbyte) $0102 =258 the question is ,is data @1,word 258 is it the same thing try it and see

    the easy way out if your not sure about data is to :-
    write 1, wordvar.highbyte, wordvar.lowbyte
    read 1 , wordvar.highbyte,wordvar.lowbyte
    its less efficient but it leaves no doubt.
    you could always read the manual or just experiment to find out , the trick is though to be able to remember it
    for next time

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Quote Originally Posted by richard View Post
    you could always read the manual
    I had referred to the manual, but just didn't comprehend how this worked...

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Uhmmm.

    Just tried
    write 10,Blue_on_Time.highbyte

    and on compiling it complains of illegal character, with a code [108].

    I've gone through the code and it compiles fine if I remove the .highbyte .... confused !!

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


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Hi,
    I copy/pasted the above line into a blank program, added Blue_On_Time VAR WORD to the top and it compiled just fine for a 16F628.
    Code:
    Blue_On_Time VAR WORD
    
    write 10,Blue_on_Time.highbyte
    
    END
    Try removing the complete line, then re-enter it or copy/paste it from your own post. Perhaps there's some strange hidden character or something lurking. Like I said, compiles just fine here.

    /Henrik.

Similar Threads

  1. When variable may not fits into WORD limitations
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2013, 09:26
  2. How to isolate 10 bits from word variable?
    By rcbandwidth123 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2008, 20:18
  3. adding new word variable ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 21st February 2008, 00:26
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 21:16
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 0

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