18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14<br />

For experienced assembly-language programmers, another reason for placing BASIC-52 in<br />

external memory is so that you can modify the source file for BASIC-52. You then can<br />

reassemble your modified source file and use the new version in your projects. In this way,<br />

you can add functions or make other changes to BASIC-52 itself. To do this, you must have<br />

a copy of BASIC-52’s source code, which has been available on Intel’s and Philips’ BBS’s,<br />

plus Intel’s ASM51 or a compatible 8051-family assembler.<br />

Iota Systems is one vendor that has customized BASIC-52 in this way, with an expanded<br />

BASIC-52 PLUS that runs from external EPROM on Iota’s 8052-BASIC boards. BASIC-52<br />

PLUS includes commands for uploading and downloading Intel Hex files, as well as other<br />

enhancements and bug fixes.<br />

Copying BASIC-52<br />

To copy BASIC-52 from ROM to NVRAM, you can use the same circuits shown in Figures<br />

3-1 and 4-3. Use a DS1225 8K NV RAM at U8. Listing 14-1 is a program that copies the<br />

8052-BASIC’s ROM from 0 to 1FFFh in internal code memory to U8 at 8000-9FFFh in<br />

external data or code/data memory. Boot up your system, enter or upload Listing 14-1 and<br />

run it. <strong>The</strong>n power down and remove the NV RAM at U8, which now contains a copy of<br />

BASIC-52.<br />

If you prefer, you can use a 28(C)64 8K EEPROM instead of NV RAM at U8. Because the<br />

write-cycle time of EEPROMs is often 2 to 10 milliseconds, you may have to slow Listing<br />

Listing 14-1. Copies the BASIC-52 interpreter program from ROM to<br />

NVRAM.<br />

10 PRINT “copying BASIC-52 from ROM to RAM at 8000h...”<br />

20 FOR I=0 TO 1FFFH<br />

30 XBY(I+8000H)=CBY(I)<br />

40 NEXT I<br />

50 PRINT “verifying...”<br />

60 X=0<br />

70 FOR I=0 TO 1FFFH<br />

80 IF XBY(I+8000H)CBY(I) THEN GOSUB 120<br />

90 NEXT I<br />

100 IF X=0 THEN PRINT “Copy successful”<br />

110 END<br />

120 PH0. “Error at location ”,I<br />

130 X=1<br />

140 RETURN<br />

240 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!