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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2048h in code memory. This is because BASIC-52 checks these locations on bootup to<br />

determine what additions have been made to BASIC-52. If you by chance have certain data<br />

stored at these locations, BASIC-52 will look for the additions it thinks you have, and crash<br />

when it doesn’t find them.<br />

If you have an EPROM addressed at 8000h, and you don’t need the entire EPROM for<br />

BASIC-52 programs, you can store your assembly-language routines in the unused area.<br />

BASIC-52’s (F)PROG command stores programs in sequence beginning at 8010h, so to<br />

leave the most room for BASIC programs, you should place your assembly-language<br />

routines in the EPROM’s highest addresses.<br />

You can also add NVRAM or EPROM in any unused area of combined code/data memory.<br />

For example, you could add an 8K NVRAM addressed from 2000h to 3FFFh, or a 16K<br />

EPROM from 4000h to 7FFFh.<br />

Software for Uploading<br />

You’ll also need a way to load your routines from your personal computer into your<br />

8052-BASIC system’s memory. All that’s required here are your host computer’s communications<br />

software and a BASIC-52 program that reads and stores the uploaded file.<br />

Appendix B contains two such programs. Listing B-1, HEX2RAM.BAS, loads Intel Hex<br />

files from your personal computer into RAM, including NVRAM, in a BASIC-52 system.<br />

Listing B-2, HEXLOAD.BAS, does the same, and also offers the options of loading into<br />

EPROM or EEPROM.<br />

On your host computer, you can the same communications software that you use to upload<br />

BASIC-52 programs, as described in Chapter 3.<br />

Another option for loading routines from your host computer into memory is to program an<br />

EPROM or other device with a device programmer, and then insert the programmed device<br />

into your BASIC-52 system. If you use this method, you can access the chip as code-only<br />

memory, rather than combined code/data memory, since you don’t need to write to it when<br />

it’s installed in the 8052-BASIC system.<br />

Loading a Routine<br />

Calling Assembly-language Routines<br />

When you have the necessary tools, you’re ready to write an assembly-language routine and<br />

assemble, upload, and call, or run, it. As a first try, we’ll begin with a very simple routine,<br />

just to verify that the circuits and techniques are working.<br />

Listing 13-1 has just one function: it toggles pin 1 (Port 1, bit 0) of the 8052. An ORG<br />

directive tells the assembler the address at which to begin loading the routine. Listing 13-1<br />

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

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

Saved successfully!

Ooh no, something went wrong!