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 13<br />

Listing 13-8. (page 1 of 2) Copies data from external memory into EPROM,<br />

EEPROM, or NV RAM.<br />

10 PRINT “enter device type: ”<br />

20 PRINT “EPROM 50-msec 1"<br />

30 PRINT “EPROM Intelligent 2"<br />

40 PRINT “EEPROM or NV RAM 3"<br />

50 PRINT “quit 4"<br />

60 INPUT T<br />

70 REM set pulse width for device type<br />

80 REM W = pulse width in milliseconds<br />

90 IF T=1 THEN W=.05<br />

100 IF T=2 THEN W=.001<br />

110 IF T=3 THEN W=.0005<br />

120 IF T=4 THEN GOTO 470<br />

130 REM calculate and store pulse width<br />

140 B=(65536-(W*XTAL/12)) : GOSUB 500<br />

150 DBY(40H)=BH : DBY(41H)=BL<br />

160 REM set up for intelligent programming or not<br />

170 I=DBY(26H)<br />

180 IF W=.001 THEN DBY(26H)=I.OR.8 ELSE DBY(26H)=I.AND.0F7H<br />

190 INPUT “starting address of data to copy (source)? ”,S<br />

200 IF S0FFFFH THEN GOTO 190<br />

210 INPUT “ending address of data to copy (source)? ”,E<br />

220 IF E0FFFFH THEN GOTO 210<br />

230 INPUT “starting address to program (destination)? ”,P<br />

240 IF P0FFFFH THEN GOTO 230<br />

250 REM calculate and store number of bytes to program<br />

260 B=(E-S)+1 : GOSUB 500 : DBY(1FH)=BH : DBY(1EH)=BL<br />

270 REM store starting address of destination-1<br />

280 B=P-1 : GOSUB 500 : DBY(1AH)=BH : DBY(18H)=BL<br />

290 PH0. “eprom low = ”,BL<br />

300 PH0. “eprom high = ”,BH<br />

236 <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!