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.

Chapter 5<br />

<strong>The</strong> address following a CALL instruction must be at least 2000h.<br />

Miscellaneous Items:<br />

Floating-point calculations have errors when the numbers are very large or very small.<br />

<strong>The</strong> value returned for the ASC(character) operator is incorrect for these seven<br />

characters:<br />

+ - = . ? / *<br />

ONTIME and ONEX1 will not cause interrupts during an INPUT statement. User delay in<br />

responding to an INPUT may cause the program to miss interrupts.<br />

Finding Program Errors<br />

Writing a program that does what you want isn’t always easy. A single missing character or<br />

program line can cause a program to stop in its tracks, or continue to execute but with<br />

unintended results, or, worst of all, crash the system and require rebooting.<br />

BASIC-52 will detect and warn you of many programming errors. If BASIC-52 detects an<br />

error when you try to run a program, it will display the line containing the error, along with<br />

an error message, and will stop the program at that point.<br />

If you get an error message, examine the offending line carefully. Many problems are due<br />

to syntax errors, where missing or incorrect characters make it impossible for BASIC-52 to<br />

interpret the program line correctly.<br />

Other times, a program will run without problems, but it won’t do what you intended. For<br />

example, it’s easy to forget that a hexadecimal number beginning in A-F must have a leading<br />

zero, or that all hexadecimal numbers must end in H. Each of these BASIC-52 statements<br />

has a different result, and none will produce an error message:<br />

BASIC-52 Statement<br />

XBY(1000H)=20H<br />

XBY(1000)=20<br />

XBY(1000H)=20<br />

XBY(1000)=20H<br />

Resulting Action<br />

Writes 20H to 1000H in external data memory<br />

Writes 14H to 3E8H in external data memory<br />

Writes 14H to 1000H in external data memory<br />

Writes 20H to 3E8H in external data memory<br />

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