Shop OBEX P1 Docs P2 Docs Learn Events
EPROM Write During Runtime — Parallax Forums

EPROM Write During Runtime

ShawnaShawna Posts: 508
edited 2013-04-28 19:54 in Propeller 1
Hey guys, I am not sure how to ask this or even search for it. The program below is a mock program, it doesn't do anything. When the prop boots up it loads 40 into KP, 50 into KI and 600 into KD. I am going to set up a routine so that I can change these values during runtime with push buttons. How do I save these values so I don't have to change them again when the Prop reboots? I do not want to have to reprogram the prop ever time I want to change these values. Do I need to use a DAT section to do this? If I use a DAT section, how do I save the changes made so that when the prop reboots the values will carry over?
CON
        _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
        _xinfreq = 5_000_000


Var
Long KP
Long KI
Long KD
OBJ


PUB Main


  Initiate_Variables


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Pub Initiate_Variables


  KP := 40
  KI := 50
  KD := 600


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Thanks
Shawn

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-04-21 19:13
    Here's a tutorial.
  • ShawnaShawna Posts: 508
    edited 2013-04-21 20:06
    Thanks, i will tear into that.
  • ShawnaShawna Posts: 508
    edited 2013-04-28 18:24
    Thanks for the link Duane.
    I played with the object and got it to work. I have a couple question though.

    1) Is there a way to use this object and rewrite the eprom location where KP KI and KD where originally saved? With this object it looks like you have to save it to the top end of the eprom and hope it doesn't overwrite any of your code.
    2) I am not real good at reading data sheets, is the max address of the 24LC256 32,000? I came up with 32,000 because every location is 8 bits(1Byte) and there is 256Kb's. 256K / 8 = 32,000.
    3) Assuming that question #2 is correct, does this mean if I store 50 Longs at the top of the eprom I could start at location 31,800? 50 Longs * 4 Bytes per Long = 200 Bytes. 32,000 - 200 = 31,800.

    Thanks
    Shawn
  • ShawnaShawna Posts: 508
    edited 2013-04-28 18:41
    Another question.
    In the propeller spin tool under view info why does the eprom address go to 7FFF (32,767)? 32,767 * 8 = 262,136Kb's
    I just looked at the 24LC256 data sheet again and it says its roll over address is also 7FFF. Why does the data sheet say the eprom has 256Kb memory if it really has 262Kb and some change?

    Just trying to learn.
    Shawn
  • kuronekokuroneko Posts: 3,623
    edited 2013-04-28 18:56
    Shawna wrote: »
    In the propeller spin tool under view info why does the eprom address go to 7FFF (32,767)? 32,767 * 8 = 262,136Kb's
    I just looked at the 24LC256 data sheet again and it says its roll over address is also 7FFF. Why does the data sheet say the eprom has 256Kb memory if it really has 262Kb and some change?
    Address range is from 0 to $7FFF (0..N-1), IOW you have 32768 bytes or 262144 bits. With K meaning 1024 (210) that comes down to 256Kb.
  • ShawnaShawna Posts: 508
    edited 2013-04-28 19:54
    Oh ya, thats right, thanks for the refresher kuroneko.
Sign In or Register to comment.