PDA

View Full Version : How do I use the extra memory in the BS2sx?



HkySk8r187
04-15-2007, 03:36 AM
I was using the BS2, which has 2k EEPROM program size ~500 lines. My program hit the limit and would no longer fit in memory. I got the error "Data occupies same location as program". I'm guessing that it's because I have about 650 lines of code so far.

So I remove hte BS2 and put on my BS2sx which says it has 8x2k EEPROM program size ~4000 lines. I get the same error, and the memory map looks identical as it did with the BS2. I thought this chip was supposed to hold 8 times the amount of code?

I don't get it. Can anyone help? Thanks.

allanlane5
04-15-2007, 03:37 AM
You need to use "multi-bank" programming.

HkySk8r187
04-15-2007, 03:43 AM
Ok guys I decided to just post my entire program. It's basically controlling some LEDs to give a light show with the beat of a song. There is going to be a lot more yet to come and I've already ran out of space. Any help would be appriciated!





' {$STAMP BS2sx}
' {$PBASIC 2.5}
LEDs VAR OUTL ' LEDs on P0 - P7
LEDsDirs VAR DIRL ' DIRs control for LEDs


SongSpeed CON 428 ' Calibration value
DeBounceTime CON 20
WholeBeatTime CON SongSpeed / 2
WholeBeatTimeNoNote CON WholeBeatTime + DeBounceTime

BtnBlank DATA %00011111
BtnG DATA %10001111
BtnR DATA %10010111
BtnY DATA %10011011
BtnB DATA %10011101
BtnO DATA %10011110

' -----[ Testing / Setup Defines ]-----------------------------------------
#DEFINE Calibrate = 0
Reset:
LEDs = %00011111 ' Start with all buttons depressed
LEDsDirs = %11111111 ' Make LEDs outputs
Main:
#IF Calibrate #THEN
DO
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
LOOP
#ENDIF
GOSUB Sequence1
END


Sequence1:

READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnY ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnY ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime

READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnY ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE DeBounceTime
READ( BtnR ), LEDs
PAUSE WholeBeatTime

READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnY ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnG ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnO ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnB ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnR ), LEDs
PAUSE WholeBeatTime
READ( BtnBlank ), LEDs
PAUSE 20
READ( BtnY ), LEDs
PAUSE WholeBeatTime


DEBUG "END OF PROGRAM!", CR
DO
PAUSE 10000
LOOP

Mike Green
04-15-2007, 04:26 AM
The way you're doing the sequencing is very wasteful of space. It looks like you're always setting certain LEDs, holding that setting for a specific time, then blanking the LEDS for 20ms ... always. You should have a DATA table in EEPROM, one byte for each beat and a pointer (index) into the table, then


BtnBlank CON %00011111
BtnG CON %10001111
BtnR CON %10010111
BtnY CON %10011011
BtnB CON %10011101
BtnO CON %10011110

table DATA BtnG, BtnR, BtnY, BtnB, BtnG, ...
DATA ' ... more and still more...
endtbl DATA 0 ' To mark the end

sequence:
i = table
do
read i,temp
i = i + 1
LEDs = temp
PAUSE WholeBeatTime
LEDs = BtnBlank
PAUSE DeBounceTime
loop until i = endtbl

HkySk8r187
04-15-2007, 08:31 AM
Thanks. Will I have enough memory to hold say 1,200 data entries?

HkySk8r187
04-15-2007, 08:33 AM
Also, how do I do "multi-bank" programming? Any examples anywhere?

Mike Green
04-15-2007, 08:41 AM
I think you would have enough memory for 1200 table entries. Worst comes to worst, you could store two entries in one byte easily enough (as nibbles) since there are really only 6 possible choices. You could even store 3 entries in a byte (6 * 6 * 6 = 216) if you needed to with only slightly more complicated code.

For a discussion of multi-slot programming, look at the PBasic manual in the section on the RUN statement and this Nuts and Volts column: www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf (http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf).

HkySk8r187
04-15-2007, 09:10 AM
Thank you Mr Green you have been most helpful! I may be coming back to these forums seeking help again when I feel stupid again :)

allanlane5
04-15-2007, 09:31 AM
Having looked at your code, you probably want to do something like the linked set of code.

This does in a single READ and a subroutine call what you did in 4 lines of code before.

HkySk8r187
04-17-2007, 11:15 AM
How could I store two entries in a byte? Using the table I have enough room to store 1200 entries, however each entry needs to have a cooresponding delay time from the previous entry.

I am not always waiting 'WholeBeatTime' after an entry, sometimes I want to wait (WholeBeatTime / 2), or (WholeBeatTime * 2)

This creates 2400 table entries for 1200 instructions, so getting even more out of the memory would be necessary.

Tracy Allen
04-17-2007, 11:45 AM
You could do that by thinking of each byte in the table as a combination of an led pattern and a time to hold it. There are six possible led patterns and I don't know how many durations, but less than 16. In each byte of data, use the low nibble as an index to the led pattern and the high nibble as an index to the duration. So in the following, action0=$21 would point to the BtnG pattern and hold it for wholeBeatTime.

Here is a modified version of the program Mike posted:



BtnBlank CON %00011111
BtnG CON %10001111
BtnR CON %10010111
BtnY CON %10011011
BtnB CON %10011101
BtnO CON %10011110

table DATA action0, action1, action2, action3, action4, ...
DATA ' ... more and still more...
endtbl DATA 0 ' To mark the end

sequence:
i = table
do
read i,temp
i = i + 1
lookup temp.nib0, [btnBlank,btnG,btnR,btnY,btnB,BtnO], LEDs ' possible patterns
lookup temp.nib1, [wbt/4,wbt/2,wbt,wbt*2,wbt*4], beatTime ' possible times
LEDs = temp
PAUSE beatTime
LEDs = BtnBlank
PAUSE DeBounceTime
loop until i = endtbl

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)