Shop OBEX P1 Docs P2 Docs Learn Events
Reading/Writing to ROM? — Parallax Forums

Reading/Writing to ROM?

firestorm.v1firestorm.v1 Posts: 94
edited 2007-05-14 23:02 in BASIC Stamp
If I have never written to a ROM location (say Location 0 for example) what will its value be if I try to read it?

Reason for this is I'm going to write a program that needs to read several locations that I have never written to in the life of my BS2. Rather than read in trash values I want to be able to go in and zero out those variables so that when the main part of the program reads the values and adjusts itself accordingly. I know that this code will only get executed once, but it is an important piece of code that will result in a reliable program/device.

I had thought of doing a start-up check of an I/O pin to see if it's high to initialize those ROM areas, otherwise do normal operation.

What do you all suggest?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-14 23:02
    There are two good choices:

    1) Write a short program that just initializes the locations you want to some useful value.· You'll download and execute this once, then download your "real" program on top of it.

    2) Include a DATA statement in your program (look in the PBasic manual) that initializes the locations with some constant whenever your program is downloaded.
Sign In or Register to comment.