Shop OBEX P1 Docs P2 Docs Learn Events
Loading external text file into BASIC Stamp — Parallax Forums

Loading external text file into BASIC Stamp

bob800bob800 Posts: 2
edited 2012-09-17 09:23 in General Discussion
Hello,

I'm trying to program a parallel EEPROM with my Basic Stamp 2. I've successfully written a single byte to the EEPROM and read from it via the Stamp, but the only way I could accomplish this was through a million hand-written "HIGH x" "LOW x" statements. Instead, I'd like to load a text file with the 0's and 1's pre-written (or, better, in hexadecimal, if that's possible).

As someone who only programs occasionally in C, I have no idea of how to accomplish this in BASIC. Any suggestions\examples would be greatly appreciated!

Thanks,

bob800

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-17 09:23
    First learn other techniques for setting I/O pins. This is all in the Basic Stamp Syntax and Reference Manual, but it's in the section on memory architecture. The I/O pins are represented as a series of predefined word variables. OUTS is the output data register. DIRS is the output direction register. INS is the input register. There are other predefined names for sections of these. OUTH is the upper 8 bits (pins 8-15) while OUTL is the lower 8 bits (pins 0-7). Similarly, there are names for groups of 4 I/O pins like OUTA (pins 0-3), OUTB (pins 4-7), OUTC (pins 8-11), and OUTD (pins 12-15). There are also names for individual I/O pins.

    Using bunches of HIGH and LOW statements to set I/O pins uses a lot of the limited (2K) program memory available.

    For loading text as part of a program, read the descriptions of the DATA and READ statements in the Reference Manual. The DATA statement will allow you to compile text strings or sequences of hex values into part of the program EEPROM and the READ statement will allow you to access this stored data. Remember that there's limited memory available and it has to be shared with the program itself. Other stamp models have larger EEPROMs that can be used for storing data. The BS2pe is the largest (16 x 2K = 32K).
Sign In or Register to comment.