Conversion of bytes to word


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102

    Default Conversion of bytes to word

    Hello. In short:

    -converted word to write it with

    Code:
    WRITE 0, WValue.BYTE0
    WRITE 1, WValue.BYTE1
    -numbers are written to the pic i can see them having read it with my programmer

    -how to convert these two hex-values to one word again ?

    Regards

    selbstdual

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    the same way dude.
    Code:
    READ 0, WValue.BYTE0
    READ 1, WValue.BYTE1
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Default

    No. I want to see a value between 0 and 65536.

    Regards


    PS: Don't call me "dude".

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Talking

    << No. I want to see a value between 0 and 65536. >>

    I suppose it must be a word ???


    << PS: Don't call me "dude". >>

    Ok, no problem, we won't any more, dude.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by selbstdual View Post
    No. I want to see a value between 0 and 65536.
    Not possible Im afraid.

    Although having declared Wvalue as a Word and read the upper and lower bytes back into it as per Mister_E's example, you should find that Wvalue contains a value between 0 and 65535.

    You can output this on a display with

    LCDout DEC Wvalue
    LCDout HEX Wvalue

    or any of the other many ways that PBP can format numbers.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  6. #6
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Default

    In short:

    -let pic collect data, write to eeprom
    -put pic in programmer
    -read pic's eeprom
    -shows something like

    2100: E0 02 1E 04 74 04 C1 05 à...t.Á.
    2108: FC 06 5D 06 C5 08 0F 08 ü.].Å...
    2110: E9 07 95 09 76 0A E1 09 é.•.v.á.
    ....

    -means: E0 02 is one pair, 1E 04 is the next one and so on
    -want to see a number between 0 and 65K instead of pairs like "E0 02".

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by selbstdual View Post
    No. I want to see a value between 0 and 65536.

    Regards


    PS: Don't call me "dude".
    Well, dude, you won't see 65536 represented in a standard word. You'll have to use 17 bits instead of 16 to get 65536.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Talking A good question is always half the answer ...

    A good question could be WHAT do you want to use to read your EEPROM ???

    - LCD DISPLAY : Mr E Gave you the answer ...

    - IDE : ah ...yes, maybe here we are !!!

    I use MPLAB, and ... I use a side calculator ( Win.calc or here Casio Fx 880 ) !!!

    No Other way in MPLAB ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Lightbulb

    You couldn't even distinguish a chair from a table and would sit on the table while wondering how to eat on the chair. This is great for comedy.

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by selbstdual View Post
    You couldn't even distinguish a chair from a table and would sit on the table while wondering how to eat on the chair. This is great for comedy.
    What's wrong with that?
    Have you defined the height of the table and the chair? I think not...
    Nor have you defined the PIC you are using, the version of PBP, which pages of the PBP manual you have looked at, which datasheets you have downloaded and studied, any websites you may have visited for information on some basic programming exercises...the list goes on...

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Thumbs down Selbstdual, Maybe ... but half brain !!!

    Quote Originally Posted by selbstdual View Post
    You couldn't even distinguish a chair from a table and would sit on the table while wondering how to eat on the chair. This is great for comedy.
    1) a Fair answer to those who can't follow your "High level Brain" wouldn't be too much, moreover it could show you're a bit clever.

    2) The last program I wrote kept side by side bits, Bytes and Words in the EEPROM ... How do you think your IDE could know by itself where are the different variable kinds ???

    3) Try to learn how to use the WRITECODE and READCODE function ( with the convenient PIC !!! ) ... If his majesty would dare !!! ... dude.

    4) another solution is to export the EEPROM content as a text File ... and decode it with an Excel sheet ( using VB Macros ...).

    'Have to Learn a bit before wanting to seat at the PIC Gurus table. ( I just serve the wine there ... and I'm really proud of it !!! )

    Alain
    Last edited by Acetronics2; - 7th February 2007 at 14:31.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    READ 0, WValue.BYTE0
    READ 1, WValue.BYTE1

    WVValue.BYTE0 = WVValue.BYTE0 * $100
    WVDVal = WVValue.BYTE0 + WVValue.BYTE1

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

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