Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual
Page 26
RPBASIC-52 PROGRAMMING GUIDE
2-7
many se ctors, the last written sec tor is filled in with mo re data from R AM. N ote that BL OAD allows data
retrieval of any length and is not affected by sector size.
T h e e as i es t w ay t o d e te r m in e a n e v e n s e c to r ad d re s s i s to " A N D " t h e E P R O M a d dr e ss w i th e it h er F F C 0H ,
FF80H, or FE00H for 32K, 128K or 512K EPR OMs respectively.
Data can be saved "ab ove" program s. The following is a way to dete rmine the ne xt free sector for writing to
flash.
1) Save the program. Note the number of bytes saved.
2) Add the sector size (based on flash EPROM type) plus 64 bytes to the number of bytes saved. (64
bytes is for program overhead). For example, suppose the program is 28145 bytes long and a 512K
(29C040) EPROM is installed. 28145 + 512 + 64 = 28721
3) At the terminal, print the following:
print 28721 .AND. 0FE00H
the response is
28672
What yo u have done is told the com puter to print the length o f the program + 512 bytes (for the sec tor) +
64 bytes (for program overhead) and 'and' it with FE00H. Notice the address, 28672, is higher than the
number of bytes saved and less than the number we figured for sector size and overhead.
4) BSA VE can be used starting at this a ddress (28672, or 70 00H).
This me thod will wo rk regardless of the nu mber of prog rams save d or segme nt numbe r.
Writing takes about 35 ms/1000 bytes. During BSAVE time, ONTICK and ON ITR interrupts are recognized
but no t servic ed. If the se com man ds mu st be se rviced quick er, writ e data in sm aller bl ocks.
RELATED
BLOA D, POKE com mands
ERRORS
B A D A R G U M E N T When any parameter is out of range or EPROM does not work properly.
H A R D W A R E
When verify to EPROM is bad
EXAMPLE
T h e fo l lo w i ng e x am p l e PO K E s d at a in t o s e g m en t 1 o f da t a R A M . T h e d a ta i s t h en s a ve d to E P R O M
segment 6 and loaded back to a different location in RAM. The data is then verified. A 128K RAM and
512K flash E PRO M m ust be in stalled for this e xam ple to w ork.
10 RA=512
20 FOR N=0 TO 1000 STEP 2
30 POKE W1,N,N
40 NEXT
50 FOR N=2000 TO 3000 STEP 2
60 POKE W1,N,0
70 NEXT
80 BSAVE6,RA,1,0,1000
90 BLOAD1,2000,6,RA,1002
100 FOR N=0 TO 1000 STEP 2
110 B=PEEKW(1,N+2000)
120 IF B<>N THEN PRINT "Error address",N," data is",B
130
NEXT