Shop OBEX P1 Docs P2 Docs Learn Events
Write Read is Jammed!!! — Parallax Forums

Write Read is Jammed!!!

HumanoidoHumanoido Posts: 5,770
edited 2009-07-22 13:45 in BASIC Stamp
Why are these very simple programs not working?
I'm expecting a 7 from the read program. It returns 0.

' {$STAMP BS1}     ' WRITE 7 into EEPROM
' {$PBASIC 1.0}
WRITE 0,7
WRITE 1,7
WRITE 2,7
WRITE 3,7
END


' {$STAMP BS1}     ' READ 7 from EEPROM
' {$PBASIC 1.0}
SYMBOL result = B0
READ 1,result
DEBUG result
END

Post Edited (humanoido) : 7/1/2009 5:08:57 PM GMT

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-07-01 14:59
    The entire eeprom is overwritten when you RUN the program. So if those are indeed two different programs, the second one will store 0's in the locatiions where the first one stored 7's.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-01 15:40
    The BS2 would be a better choice for this kind of programming, since only those EEPROM locations that contain program bytes or data are written during uploading.

    -Phil
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-01 16:54
    Tracy Allen: thanks for solving this mystery!
    Phil Pilgrim: thanks for the BS2 information.

    Yes, it's two programs, and this explains
    why it was coming up with zeros in the EEPROM
    after running the second program. I read those
    Stamp 1 book sections over and over and
    apparently missed this part. Thanks for the
    help.

    Below is the text that I was reading which led me
    to believe long term data could be stored into the
    BS1 and read back. Maybe this is talking about
    external added EEPROM which is handled different?

    attachment.php?attachmentid=61943

    The application requires the BS1, and the
    solution is to put all the code in one program and
    keep it running.

    humanoido

    Post Edited (humanoido) : 7/1/2009 5:11:40 PM GMT
    478 x 244 - 46K
  • unknownunknown Posts: 10
    edited 2009-07-02 05:08
    What if you made the program display the data when you sent it a bit of info in the Debug terminal? I'm not sure if the BS1 supports the DEBUGIN command.
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-02 07:23
    It's a challenge because there is no DEBUGIN.
  • unknownunknown Posts: 10
    edited 2009-07-22 13:06
    Scratch that debugin, I made a bs2 program, and I'll put it here. I'll convert it to bs1 soon.
    here it is
    
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    

    rc_time   VAR Byte
    address   VAR Word
    starttest VAR Byte
    

    READ 0, starttest
    IF (starttest = 0) THEN
      GOTO datalog
    ELSE
      GOTO debugresults
    ENDIF
    

    datalog:
      FOR address = 0 TO 50
        HIGH 1
        PAUSE 3
        LOW 1
        RCTIME 1, 1, rc_time
        WRITE address, rc_time
        SLEEP 782
      NEXT
    END
    

    debugresults:
      DEBUG cls
      FOR address = 0 TO 50
        READ address, rc_time
        DEBUG ? address
      NEXT
    stop
    

    
                            
  • unknownunknown Posts: 10
    edited 2009-07-22 13:45
Sign In or Register to comment.