ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 2102
Скачиваний: 0
Chapter 5
ONERR line number |
R |
|
Passes control to line number following an arithmetic error. Arithmetic errors in- |
||
clude ARITH. OVERFLOW, ARITH. UNDERFLOW, DIVIDE BY ZERO, and |
||
BAD ARGUMENT. |
||
ONEX1 line number |
R |
|
On interrupt 1 (pin 13), BASIC-52 finishes executing the current statement, and |
||
then passes control to an interrupt routine beginning at line number. The interrupt |
||
routine must end with RETI. |
||
ONTIME number of seconds, line number |
R |
|
When TIME = number of seconds, BASIC-52 passes control to an interrupt rou- |
||
tine beginning at line number. The interrupt routine must end with RETI. |
||
CLOCK1 starts the timer. |
||
expression .OR. expression |
C,R |
|
Logical OR |
||
P. |
||
same as PRINT |
||
PCON |
C,R |
|
Retrieves or assigns a value to the 8052’s special function register PCON. |
||
PGM |
C,R |
|
Programs an EPROM, EEPROM, or NV RAM with data from memory. The fol- |
||
lowing data must be stored in internal data memory in the locations listed: |
||
1Bh,19h |
High byte, low byte of first address of data to program |
|
1Ah,18h |
High byte, low byte of first address to be programmed - 1 |
|
1Fh,1Eh |
High byte, low byte indicating number of bytes to program |
|
40h,41h |
High byte, low byte indicating width of programming pulse. |
|
High byte = ((65536 - pulse width in seconds * XTAL/12) / 256. |
||
Low byte = ((65536 - pulse width in seconds * XTAL/12) .AND. 0FFh. |
||
26h |
For Intelligent programming, set bit 3. |
|
For 50-millisecond programming, clear bit 3. |
||
PH0. |
C,R |
|
Same as PRINT, but displays values in hexadecimal format. Uses two digits to |
||
display values less than 0FFh. |
||
PH0.# |
C,R |
|
Same as PRINT#, but displays values in PH0. hexadecimal format |
||
80 |
The Microcontroller Idea Book |
Programming |
|
PH0.@ |
C,R |
Same as PRINT@, but outputs values in PH0. hexadecimal format. |
|
PH1. |
C,R |
Same as PRINT, but displays values in hexadecimal format. Always displays |
|
four digits. |
|
PH1.# |
C,R |
Same as PRINT#, but displays values in PH1. hexadecimal format. |
|
PH1.@ |
C,R |
Same as PRINT@, but outputs values in |
PH1. hexadecimal format. |
PI |
C,R |
Constant equal to 3.1415926. |
|
POP variable [,...variable] |
C,R |
Assigns the value of the top of the argument stack to variable. |
|
PORT1 |
C,R |
Retrieves or assigns a value to PORT1 (pins 1-8). |
|
PRINT [expression] [,...expression] [,] |
C,R |
Displays the value of expression(s) on the host computer. A comma at the end of the statement suppresses the CARRIAGE RETURN/LINEFEED. Values are separated by two spaces. Additional PRINT options are CR, SPC, TAB, USING.
PRINT# |
C,R |
Same as PRINT, but outputs to LPT (pin 8). BAUD and XTAL values affect the |
|
PRINT# rate. |
|
PRINT@ |
C,R |
Same as PRINT, but outputs to a user-defined output driver. Requires an assem- |
|
bly-language output routine at 403Ch in external program memory. Setting bit 7 |
|
of internal data memory location 24h enables the output routine. |
|
PROG |
C |
Stores the current RAM program in the EPROM space. |
The Microcontroller Idea Book |
81 |
Chapter 5
PROG1 |
C |
Saves the serial-port baud rate. On power-up or reset, BASIC-52 boots without |
|
having to receive a space character. The terminal’s baud rate must match the |
|
stored value. |
|
PROG2 |
C |
Like PROG1, but on power-up or reset, BASIC-52 also begins executing the first |
|
program in the EPROM space. |
|
PROG3 |
C |
Like PROG1, but also saves MTOP. On power-up or reset, BASIC-52 clears |
|
memory only to MTOP. |
|
PROG4 |
C |
Like PROG2, but also saves MTOP. On power-up or reset, BASIC-52 clears |
|
memory only to MTOP. |
|
PROG5 |
C |
Like PROG3, but also reads 5Fh in external data memory on power-up or reset. |
|
If 5Fh contains 0A5h, BASIC-52 doesn’t clear external data memory. If data |
|
memory location 5Eh contains 34h, BASIC-52 will automatically begin execut- |
|
ing a program in external data memory. |
|
PROG6 |
C |
Like PROG5, but if external data memory location contains 5Fh, BASIC-52 calls |
|
a user-written assembly-language reset routine beginning at program memory |
|
4039h. |
|
PUSH expression [,...expression] |
C,R |
Places the values of expression(s) sequentially on BASIC-52’s argument stack. |
|
PWM expression1, expression2, expression3 |
C,R |
Outputs a pulse-width modulated (PWM) sequence of pulses on pin 3. Expres- |
|
sion1 is the width of each high pulse, expressed in clock cycles. Expression2 is |
|
the width of each low pulse, expressed in clock cycles. Expression3 is the number |
|
of PWM cycles output. One clock cycle = 12/XTAL. One PWM cycle = one high |
|
pulse plus one low pulse. Expression1 and Expression2 must each be at least 25. |
|
Maximum for each Expression is 65535. |
|
RAM |
C |
Selects the current program in the RAM space. |
82 |
The Microcontroller Idea Book |
Programming |
|
RCAP2 |
C,R |
Retrieves or assigns a value to the 8052’s special function registers RCAP2H and |
|
RCAP2L. |
|
READ variable [,...,variable] |
R |
Retrieves the expressions in a DATA statement and assigns each expression to a |
|
variable. |
|
REM |
C,R |
Introduces a comment, or remark. BASIC-52 ignores all text after |
REM in a pro- |
gram line. |
|
RESTORE |
R |
Resets READ pointer to the first expression in the DATA statement. |
|
RETI |
R |
Returns program control to the line number following the most recently executed |
|
ONEX1 or ONTIME statement. |
|
RETURN |
R |
Returns program control to the line number following the most recently executed |
|
GOSUB statement. |
|
RND |
C,R |
Returns a pseudo-random number between 0 and 1 inclusive. |
|
ROM [program number] |
C |
Selects a program in the EPROM space (beginning at 8000h). Default program |
|
number is 1. |
|
RROM [program number] |
C,R |
Changes to ROM mode and runs the specified program. Default program number |
|
is 1. |
|
RUN |
R |
Executes the current program. Clears all variables. |
|
SGN (expression) |
C,R |
Returns +1 if expression >=0, zero if expression = 0, and -1 if expression <0. |
|
SIN(expression) |
C,R |
Returns the sine of expression |
|
The Microcontroller Idea Book |
83 |
Chapter 5
SPC(expression)
PRINT option. Causes the display to place expression additional spaces (besides the minimum two) between values in a PRINT statement.
Example: |
||
PRINT “hello”,SPC(3),"good-by" |
||
hello |
good-by |
|
SQR(expression) |
C,R |
|
Returns square root of expression. |
||
ST@ expression |
C,R |
|
Copies a 6-byte floating-point number from the argument stack to external data |
||
memory. Expression points to the most significant byte of the number. |
||
STOP |
||
Halts program execution. |
||
STRING expressions, expression2 |
C,R |
|
Allocates memory for strings (variables each consisting of a series of text charac- |
||
ters). |
||
Expression1 = (Expression2 * number of strings) + 1. |
||
Expression2 = maximum number of bytes (characters) per string + 1. Executing |
||
STRING clears all variables. Maximum number of strings is 255. |
||
Examples: |
||
STRING 91,9 |
||
reserves space for ten 8-character strings |
||
STRING 9,4 |
||
reserves space for two 3-character strings |
||
T2CON |
C,R |
|
Retrieves or assigns a value to the 8052’s special function register T2CON. |
||
TAB(expression),
PRINT option. Specifies the position (number of spaces) to begin displaying the next value in the PRINT statement.
Example:
PRINT TAB(5) “hello” hello
84 |
The Microcontroller Idea Book |