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.

Appendix B<br />

Listing B-2 (page 3 of 4).<br />

rem Store the data in RAM<br />

1500 FOR I=SOURCE TO SOURCE + COUNT-1 : XBY(ADDR)=XBY(I)<br />

rem Now verify that stored data is readable as code<br />

1505 if XBY(I) CBY(ADDR) THEN GOTO 3130<br />

1508 ADDR = ADDR+1 : NEXT<br />

1510 RETURN<br />

rem Store the data in EPROM or RDY/BUSY EEPROM<br />

rem First load the source address registers<br />

1520 DBY (1BH) = SOURCE/256 : DBY (19H) = SOURCE .AND. 0FFH<br />

rem Now load the destination address registers<br />

1530 DBY (1AH) = (ADDR-1)/256 : DBY (18H) = (ADDR - 1)<br />

.AND. 0FFH<br />

rem Now load the number of bytes to program<br />

1540 DBY (1Fh) = COUNT/256 : DBY (1Eh) = COUNT .AND. 0FFh<br />

rem Program the data into the part<br />

1550 PGM : IF DBY (1Fh) .OR. DBY (1Eh) 0 THEN GOTO 3060<br />

1560 RETURN<br />

1570 FOR I=SOURCE TO SOURCE + COUNT-1 : XBY (ADDR) = XBY<br />

(I)<br />

1580 time = 0 : dby (47h) = 0 : clock1 : do : until time >=<br />

delay<br />

1590 if xby (addr) xby (i) goto 3100<br />

1600 addr = addr + 1: clock0 : next : clock0 : return<br />

rem Convert the ASCII text to numbers<br />

2000 C = ASC($(0),I) : IF (C=65) THEN C = C -<br />

55 ELSE C = C - 48<br />

2020 CH = C * 16 : C = ASC($(0),I + 1)<br />

2040 IF (C=65) THEN C = C - 55 ELSE C = C - 48<br />

2050 CH = CH + C : RETURN<br />

rem Here when we are going to load the data into EEPROM.<br />

2100 WAIT = 0.0005 : RETURN<br />

rem Here for Intelligent programming<br />

2110 WAIT = 0.001 : RETURN<br />

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