Data memory - explanation please


Closed Thread
Results 1 to 10 of 10

Hybrid View

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

    Default Data memory - explanation please

    Hi,

    I have two sets of data stored in the PIC -
    Data @0,0 and Data @150

    I want to save 10 arrays each with 4 values ( eg tempset(1), tempset(2), etc) to the PICs memory, which can then be read back on power up, but I'm not sure at what location I should save them to as the data table is in hex



    Could someone explain, or come up with a revision of the memory map to make better use of it ?

    Thanks

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I'm convinced that I am missing something, but why can't you just save them as follows:

    For X = 0 to 3
    Write X,Array1[X]
    Next X

    For X = 4 to 7
    Write X,Array2[X-4]
    NextX

    ...
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    Hi Charles,

    Sorry, please bear with me as this is the first time I've experimented with saving data other than when programming mode.

    I want to save the following to the PIC once the user has set them so that in the event of a power failure they are remembered and the user doesn't have to re-enter the data.

    Code:
    save:
    Lcdout $FE,2
    LCDOUT $FE,$80,"Saving Settings"
    for fn= 0 to 3
    write ,lightsetHR[fn]
    write ,lightsetMN[fn]
    write ,lightoffHR[fn]
    write ,lightoffMN[fn]
    write ,droptemp[fn]
    write ,normtemp[fn]
    write ,StartHour[fn]
    write ,StartMin[fn]
    write ,StopHour[fn]
    write ,StopMin[fn]
    next fn
    pause 150
    goto mainmenu
    However as the program writes data to the memory at the time of programming and as part of the RTC settings (data@ 0,0 and data@150 respectively) I'm not sure what value to place before the colon after the word statement for each of the above. I don't want to corrupt the data stored at those data locations.

    For example - 0x50 address in that table appears blank (FF) - so could I use
    Code:
    write 0x50 ,lightsetHR[fn]
    Or whatever decimal 0x50 would be ???

    Hope that's clear ?

    Oh and I'm using DT's interrupts... would I need to use DEFINE WRITE_INT 1 withing that sub-routine ?
    Last edited by malc-c; - 1st August 2010 at 18:40. Reason: had an additional thought !

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


    Did you find this post helpful? Yes | No

    Default

    Yes, you can use 0x50 if you want to. There is nothing written there. Since 0x50h = 80 you can use something like this

    Code:
    for fn= 0 to 3
      write (10*fn + 80),lightsetHR[fn]
      write (10*fn + 81),lightsetMN[fn]
      write (10*fn + 82),lightoffHR[fn]
      write (10*fn + 83),lightoffMN[fn]
      write (10*fn + 84),droptemp[fn]
      write (10*fn + 85),normtemp[fn]
      write (10*fn + 86),StartHour[fn]
      write (10*fn + 87),StartMin[fn]
      write (10*fn + 88),StopHour[fn]
      write (10*fn + 89),StopMin[fn]
    next fn
    I haven't tested this code so I don't know if the (10*fn + 8x) works in the WRITE command. If it doesn't then try something like this

    Code:
    for fn= 0 to 3
      Mem_address = (10*fn) + 80
      write Mem_Address,lightsetHR[fn]
      Mem_address = (10*fn) + 81
      write Mem_address,lightsetMN[fn]
      Mem_address = (10*fn) + 82
      write Mem_address,lightoffHR[fn]
      Mem_address = (10*fn) + 83
      write Mem_address,lightoffMN[fn]
      Mem_address = (10*fn) + 84
      write Mem_address,droptemp[fn]
      Mem_address = (10*fn) + 85
      write Mem_address,normtemp[fn]
      Mem_address = (10*fn) + 86
      write Mem_address,StartHour[fn]
      Mem_address = (10*fn) + 87
      write Mem_address,StartMin[fn]
      Mem_address = (10*fn) + 88
      write Mem_address,StopHour[fn]
      Mem_address = (10*fn) + 89
      write Mem_address,StopMin[fn]
    next fn

    Quote Originally Posted by malc-c View Post
    Oh and I'm using DT's interrupts... would I need to use DEFINE WRITE_INT 1 withing that sub-routine ?
    You need to disable the interrupts for the WRITE command to work. I read somewhere in this forum that the WRITE_INT is only for WRITECODE, but you might want to try it.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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


    Did you find this post helpful? Yes | No

    Default

    Robert,

    Thanks for the assistance. I'll give it a try and no doubt will be back with some feedback

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


    Did you find this post helpful? Yes | No

    Default

    Robert,

    Thank you. The first version works a treat !

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