writing word variables to data memory


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry I might not of got the point over

    lightsetHR[fn]
    lightsetMN[fn]

    lightoffHR[fn]
    lightoffMN[fn]

    droptemp[fn]
    normtemp[fn]

    StartHour[fn]
    StartMin[fn]
    StopHour[fn]
    StopMin[fn]

    alarmhigh[fn]
    alarmlow[fn]


    They are all WORD variables, but as all those in blue have values that are typically two digits (eg Hours will be between 00 and 23, with minutes being 00 to 59). they get saved and read OK for some reason. All those in red will be three digit values, eg 327, 150 and it's these that don't get saved. Each Word variable has 4 elements for example ,

    alarmhigh[0]
    alarmhigh[1]
    alarmhigh[2]
    alarmhigh[3]

    These will have different values depending on what has been set in a previous section
    eg:

    alarmhigh[0]=340
    alarmhigh[1]=360
    alarmhigh[2]=400
    alarmhigh[3]=370

    Hope that helps clarify my issue

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Malc

    Did you simply tried to Open the Holy Manual ???

    supposing you use the PBP 2.60a Version ... it is at page 175 ...

    supposing you use previous version ( 2.50b ) ... it is at page 162 ...

    examples for WORDs given.

    You also should have a look to $ 4.4 p 25 " Aliases " ... where it is shown how to " slice " your values ...

    Alain
    Last edited by Acetronics2; - 5th August 2010 at 12:08.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Malc

    Did you simply tried to Open the Holy Manual ???



    Alain
    http://www.picbasic.co.uk/forum/show...2176#post92176

    Just don't quite understand it... (sorry I'm thick ! - care to actually explain how I would do this " Aliases " ... where it is shown how to " slice " your values thing ?)

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    http://www.picbasic.co.uk/forum/show...2176#post92176

    Just don't quite understand it... (sorry I'm thick ! - care to actually explain how I would do this " Aliases " ... where it is shown how to " slice " your values thing ?)
    Ok Malc ...

    let's make it easy :

    The last PBP2.60 Version has introduced a Qualifier that permits you NOT to care with slicing your variables ...
    so, if you own a v2.60 ( and You SHOULD ) ... the link you gave me becomes ... obsolete.

    as you, NOW, just have to write:

    WRITE Location, Word AlarmHigh[1] , Word AlarmHigh[2] , Word AlarmHigh[3] ,...

    READ Location, Word AlarmHigh[1], Word AlarmHigh[2] , Word AlarmHigh[3], WA[1],WA[2],WA[3]

    BUT remember a word need 2 EEPROM locations ... so,

    WRITE Location +6 , Word AlarmHigh[4]
    READ Location +6 , Word AlarmHigh[4] ,WA4

    Alain

    PS: of course, you can keep on using the " old method "

    WRITE Location, AlarmHigh[1].Lowbyte
    WRITE Location+1, AlarmHigh[1].Highbyte
    WRITE Location+2, AlarmHigh[2].Lowbyte
    WRITE Location+3, AlarmHigh[2].Highbyte
    WRITE Location+4, AlarmHigh[3].Lowbyte
    WRITE Location+5, AlarmHigh[3].Highbyte
    WRITE Location+6, AlarmHigh[4].Lowbyte
    WRITE Location+7, AlarmHigh[4].Highbyte

    ... but, is it really reasonnable ???
    Last edited by Acetronics2; - 5th August 2010 at 13:53.
    ************************************************** ***********************
    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
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    The part I really find it hard to grasp is the WA[1], WA[2] bit and how to format the two eprom locations

    So assuming the start address is 80

    Could this then be changed to
    Code:
    For x = 0 to 3
    For fn = 0 to 8
    Write Word (80+fn) AlarmHigh[fx] highbyte
    If fn >= 4 then 
    x = 0 
    Write Word (80+fn) AlarmHigh[fx] lowbyte
    Next fn
    Next x
    I just can't seem to make this sink in !

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=malc-c;92222]

    So assuming the start address is 80

    Could this then be changed to
    Code:
    For x = 0 to 3
    For fn = 0 to 8
    Write Word (80+fn) AlarmHigh[fx] highbyte
    If fn >= 4 then 
    x = 0 
    Write Word (80+fn) AlarmHigh[fx] lowbyte
    Next fn
    Next x
    Oh my god ... you really thick ... ( YOU told it, not me ... )

    following your explanation:

    [code]

    For fn = 0 to 3
    Write (80+2*fn), Word AlarmHigh[fn+1]
    next fn

    [code]

    LOCATION MUST BE PLACED BEFORE THE DATA !!!

    ( sorry for other users , but it's the 4 th time I repeat ... )


    Business looks to have turned you deaf and blind ...

    Alain
    Last edited by Acetronics2; - 5th August 2010 at 21:26.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    This seems to compile

    Code:
      for fn = 0 to 3
      write (10*fn + 80),lightsetHR[fn]
      write (10*fn + 82),lightsetMN[fn]
      write (10*fn + 84),lightoffHR[fn]
      write (10*fn + 86),lightoffMN[fn]
      write (10*fn + 88),word droptemp[fn]
      write (10*fn + 90),word normtemp[fn]
      write (10*fn + 92),StartHour[fn]
      write (10*fn + 94),StartMin[fn]
      write (10*fn + 96),StopHour[fn]
      write (10*fn + 98),StopMin[fn]
      write (10*fn + 100),word alarmhigh[fn]
      Write (10*fn + 102),word alarmlow[fn]
      next fn

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