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.

Calling Assembly-language Routines<br />

Listing 13-8. (page 2 of 2)<br />

310 REM store starting address of source<br />

320 B=S : GOSUB 500 : DBY(1BH)=BH : DBY(19H)=BL<br />

330 PH0. “ram low = ”,BL<br />

340 PH0. “ram high = ”,BH<br />

350 PRINT “press ENTER to begin programming”<br />

360 X=GET : IF X0DH THEN 360<br />

370 REM program the EPROM<br />

380 PRINT “programming in progress...”<br />

390 PGM<br />

400 REM check for errors<br />

410 IF (DBY(1EH).OR.DBY(1FH))=0 THEN PRINT “programming OK”<br />

: GOTO 470<br />

420 REM on error, calculate address that failed to program<br />

430 DC=DBY(19H)+256*DBY(1BH)-1<br />

440 PH0. “ERROR: Source address ”,DC," = “,XBY(DC)<br />

450 DP=DBY(18H)+256*DBY(1AH)<br />

460 PH0. “ Destination address ”,DP," = “,XBY(DP)<br />

470 END<br />

500 REM separate B into high (BH) and low (BL) bytes<br />

510 BL=(B.AND.0FFH)<br />

520 BH=INT(B/256)<br />

530 RETURN<br />

A General-purpose EPROM Programmer<br />

With Listing B-2, you can use an 8052-BASIC system as a general-purpose programmer<br />

for EPROM, EEPROM, or NV RAM. <strong>The</strong> program will read any file in Intel Hex format,<br />

and store it at the addresses specified in the file.<br />

For example, you can add a socket for an 8K EPROM, EEPROM, or NV RAM addressed<br />

at A000h-BFFFh in combined code/data memory. For EEPROM or NVRAM, wire the<br />

socket exactly like U8 in Figure 4-3, except wire pin 1 of U9 to chip-select A000h (pin 10<br />

of U6 in Figure 3-1) instead of to 8000h. For EPROM programming, also connect Figure<br />

4-5’s circuits to pins 1 and 28 of the EPROM, for the programming voltages.<br />

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

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

Saved successfully!

Ooh no, something went wrong!