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.

Appendix B<br />

Listing B-2 (page 1 of 4). HEXLOAD.BAS copies an Intel Hex file into RAM,<br />

EEPROM, or EPROM in an 8052-BASIC system.<br />

1 STRING 82, 80<br />

2 PRINT TAB(22),"HEX FILE LOADING PROGRAM 1.2"<br />

3 PRINT TAB(14), “(C) 1990,1991 Systronix Inc. All rights<br />

reserved.” : PRINT<br />

4 PRINT “This program accepts as input, an Intel format hex<br />

file and stores”<br />

5 PRINT “it in RAM, EPROM, or EEPROM at the addresses specified.”<br />

: PRINT<br />

6 PRINT : PRINT “Select the destination device type:” :<br />

PRINT<br />

7 PRINT TAB(10), “[1] RAM” : PRINT TAB(10), “[2] Timed<br />

EEPROM”<br />

8 PRINT TAB(10), “[3] EPROM (Intelligent algorithm)”<br />

9 PRINT TAB(10), “[4] EPROM (50mS algorithm)”<br />

10 PRINT TAB(10), “[5] EEPROM (RDY/BUSY type)”<br />

11 INPUT “Select Device Type (1, 2, 3, 4, 5) >> ”, TYPE<br />

12 IF (TYPE < 1) .OR. (TYPE 5) THEN PRINT CHR(7) : GOTO 11<br />

20 TYPE=TYPE-1 : IF TYPE = 0 THEN GOTO 1300<br />

21 if type = 1 then goto 22 else goto 30<br />

22 INPUT “Delay between writes >> ”, delay : goto 1300<br />

30 ON (TYPE) GOSUB 2100, 2100, 2110, 2120, 2100<br />

40 IF TYPE = 2 THEN DBY(38) = DBY(38) .OR. 8 ELSE DBY(38) =<br />

DBY(38) .AND. 0f7H<br />

rem Calculate and store pulse width<br />

50 WAIT = 65536-WAIT*XTAL/12 : DBY(40H) = WAIT/256 :<br />

DBY(41H) = WAIT.AND.0ffH<br />

1300 PRINT “Ready to receive the input file one line at a<br />

time. Set your”<br />

1310 PRINT “communication software to send a line when when<br />

it receives”<br />

1320 PRINT “the ’>’ prompt.” : PRINT<br />

1330 SOURCE = MTOP - FREE + 1<br />

1340 LINE = LINE + 1 : INPUT">", $(0) : PRINT “Validating<br />

input buffer ...”,<br />

1350 I = 1 : C = ASC($(0),1) : IF C58 THEN GOTO 3000 :<br />

REM if not “:”<br />

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