[SOLVED !] Float values in an external EEPROM


Closed Thread
Results 1 to 3 of 3

Thread: Float values in an external EEPROM3978 days old

  1. #1
    keystoneclimber
    Guest keystoneclimber's Avatar

    0 Not allowed!

    Default Float values in an external EEPROM

    I would like to store some floating point values in an external SPI EEPROM. I understand the concept for storing floating point values with 4 byte variables a la Microchip's modified IEEE-754 format. Does the compiler have a method for sending floats via SHOUT i.e. something to this effect:

    SHOut SDATA,SCLK,msbfirst,[floatvar]

    ...where it would convert behind the scenes and send the 4 byte variables that represent the float variable for storage in the external EEPROM, or would I need to write a routine to do the conversion, then send and store each of the 4 bytes individually?

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    keystoneclimber
    Guest keystoneclimber's Avatar

    0 Not allowed!

    Default

    I found a partial answer to my own question. According to this thread:
    http://www.picbasic.org/forum/showth...highlight=ieee

    I should be able to do this...

    SHOut SDATA,SCLK,msbfirst,[floatvar]

    ...assuming the SHOut command works similar to the BUSOUT command. When I tried this, I found that it only transmitted the digits preceding the decimal.

    Now to complicate matters.

    Using...

    SHOut SDATA,SCLK,msbfirst,[floatvar.Byte0, floatvar.Byte1, floatvar.Byte2, floatvar.Byte3]

    ...works well and produces the expected results, but using this...

    SHOut SDATA,SCLK,msbfirst,[floatvar, floatvarH, floatvarHH, floatvarHHH]

    produces results with a first term (floatvar) that differs from floatvar.Byte0. Is this expected, and did I misinterpret the original thread in that these two statements should be functionally equivalent? Thanks.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,465
    Thumbs Up
    Received: 305
    Given: 145
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default

    You shouldn't use the seperated variable types (i.e. H, HH, HHH) in this way, as not all of them are byte types.

    The correct use to send a float is with the compiler's high-level variable splitters:-

    Shout SDATA,SCLK,msbfirst,[floatvar.Word0\16, floatvar.Word1\16]

    This will send the float as 2 16-bit blocks, which is more efficient than individual bytes. However, if the eeprom has page boundaries, it may be necessary to send individual bytes. In which case, a variation of you're first code snippet is required:

    Shout SDATA,SCLK,msbfirst,[floatvar.Byte0]
    DelayMs 5
    Shout SDATA,SCLK,msbfirst,[floatvar.Byte1]
    DelayMs 5
    Shout SDATA,SCLK,msbfirst,[floatvar.Byte2]
    DelayMs 5
    Shout SDATA,SCLK,msbfirst,[floatvar.Byte3]
    DelayMs 5

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. How to send a word array to an eeprom like the 24C32 eeprom
      By yvesmazzon in forum Tips 'n Tricks
      Replies: 2
      Last Post: 4th February 2017, 23:01
    2. serin float values
      By Ghazanfer in forum Proton Plus Compiler v3
      Replies: 14
      Last Post: 3rd March 2013, 00:37
    3. [SOLVED !] External eeprom problem - writing to all addresses
      By Dave-S in forum Proton Plus Compiler v3
      Replies: 13
      Last Post: 29th December 2011, 01:17
    4. External EEPROM READ/WRITE Problem
      By CharlieBrown in forum Proton Plus Compiler v3
      Replies: 3
      Last Post: 23rd July 2010, 10:34
    5. [SOLVED !] External I2C EEPROM table or float point math?
      By pinko in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 24th July 2009, 16:03

    Tags for this Thread

    Posting Permissions

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