8bit var holds 16bit data!??


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    pwhitt's Avatar
    pwhitt Guest


    Did you find this post helpful? Yes | No

    Default

    <i>"The problem is:
    You are outputting a VAR that has been declared as BYTE with a resolution of 16 bits, that doesn't make much sense, does it?"</i>

    NavMicroSystems, if you mean the output of the HSEROUT statement:

    HSEROUT ["0-5=", ~Result+1]

    No, I'm outputting the result of a 16bit operation, not a VAR at all (this would likely end up in a terminal full of garbage - not numbers at all). I should have been more clear and typed:

    HSEROUT ["0-5+",BIN ~Result+1]
    which should yield: 1111111100000101 and I think this corresponds to the incorrect value given above.

    However if our friend Mofarngo were to write this value to Result first, the leading word would be truncated, resulting in: 00000101, which is what he wants.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    pwhitt is right. When you include the equation inline with HSEROUT ["0-5=", ~Result+1] you're telling PBP to output the "result" of ~result+1.

    And since the compliment is handled as a 16-bit operation, HSEROUT is going to send a 16-bit result computed internally by the inline equation ~result+1.

    You can see how this works with something like this;

    HSEROUT ["100 * 50 = ", DEC 100*50,13,10]

    Note there's no reference to any variable. Only an equation. That's pretty much the same thing as passing ~result+1 to HSEROUT. It's going to print the result of the equation, and not the byte variable result.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    mofarngo's Avatar
    mofarngo Guest


    Did you find this post helpful? Yes | No

    Default

    thanks guys - that was a stupid oversight on my part.

    i was doing exactly "serout [~result+1]" to get the result.

    writing the result to the var and then sending over serial fixed it right away. oops!

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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