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.

memory on bootup. This is what allows you to disconnect the system from its host and run<br />

it as a stand-alone system.<br />

You can also permanently store a value for MTOP in U8. If you have a 32K RAM at U7,<br />

storing MTOP will ensure that you can use FPROG, and that your stored programs will be<br />

preserved when you reboot or power down.<br />

If U7 is 32K, type<br />

MTOP=7FFFH<br />

FPROG3<br />

Now, when your system boots up, MTOP will automatically be set to 7FFFh. FPROG3 also<br />

saves the baud rate and boots to the READY prompt without requiring you to press the space<br />

bar.<br />

If you want to save MTOP and also run a program on bootup, use FPROG4, which combines<br />

the features of FPROG2 and FPROG3. FPROG5 is another useful command. It prevents<br />

BASIC-52 from clearing external data memory on bootup. FPROG6 enables you to add<br />

your own assembly-language reset routine.<br />

If you use FPROG2-FPROG6, BASIC-52 will no longer auto-detect your host’s baud rate.<br />

You must use the baud rate and crystal value that were in use when you executed the FPROG<br />

command.<br />

Erasing NV Memory<br />

Saving Programs<br />

Eventually, your NVRAM or EEPROM will fill with programs, or you may just want to<br />

erase what you’ve stored and start fresh. Listing 4-1 is a program that erases U8 by writing<br />

0FFh to all locations.<br />

To use the program, enter the listing and type RUN. <strong>The</strong> READY prompt will return when<br />

erasing is complete. Line 30 verifies each erasure, and is required only for EEPROM,<br />

Listing 4-1. Erases NVRAM or EEPROM.<br />

10 FOR I=8000H TO 9FFFH<br />

20 XBY(I)=0FFH<br />

30 IF XBY(I)0FFH THEN GOTO 30<br />

40 NEXT I<br />

50 END<br />

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

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

Saved successfully!

Ooh no, something went wrong!