writing word variables to data memory


Results 1 to 14 of 14

Threaded View

  1. #12
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    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
    Malcolm,

    This code won't work anymore like Alain already mentioned. Now, you have words instead of bytes. Also, now you have 12 variables instead of 10 .

    Now, if you try to write 12*2*4=96 bytes at location 80 then you are going to overwrite all the stuff that you wrote at location 150 with your DATA command (from your other post).

    I would suggest that you should try first to clear up the mess by organizing the data that you put in EEPROM. It looks like the amount of data that you are putting in memory by doing "Data @0,0 and Data @150" is 58 bytes for each DATA command. So, instead of "Data @0,0 and Data @150" try something like "Data @0,0 and Data @58". Then from location 116 and up you have no data that could get overwritten.

    Next, try the same code as above but with the following changes.

    Code:
    for fn = 0 to 3
      write (12*fn + 116),lightsetHR[fn]
      write (12*fn + 118),lightsetMN[fn]
      write (12*fn + 120),lightoffHR[fn]
      write (12*fn + 122),lightoffMN[fn]
      write (12*fn + 124),word droptemp[fn]
      write (12*fn + 126),word normtemp[fn]
      write (12*fn + 128),StartHour[fn]
      write (12*fn + 130),StartMin[fn]
      write (12*fn + 132),StopHour[fn]
      write (12*fn + 134),StopMin[fn]
      write (12*fn + 136),word alarmhigh[fn]
      write (12*fn + 138),word alarmlow[fn]
    next fn
    I replaced 10 by 12 since now you have 12 variables. I hope that this helps.

    Robert
    Last edited by rsocor01; - 6th August 2010 at 00:23.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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