BASIC 52

Instructions Set


MANUALE Tecnico in ITALIANO (Concentrato) MCS®-BASIC 52

MANUALE del Linguaggio in ITALIANO (Integrale) MCS®-BASIC 52

MCS®-BASIC 52 Intel - in INGLESE MCS®-BASIC 52 Intel

BASIC GPC® 323 - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52 Intel, per CPU fam. 80C32
Edizione 3.50

BASIC GPC® 323D - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52, per CPU Dallas 80C320
Edizione 3.20

BASIC GPC® 324 - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52 Intel, per CPU fam. 80C32
Edizione 3.20

BASIC GPC® 324D - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52, per CPU Dallas 80C320
Edizione 3.50

BASIC GPC® 552 - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52, per CPU Philips fam. 80C552
Edizione 3.20

BASIC GPC® 553 - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52, per CPU Philips fam. 80C552
Edizione 3.10

BASIC GPC® 554 - PDF Short Guide - BASIC Interpretato, MCS® BASIC-52, per CPU Philips fam. 80C552
Edizione 3.10


L I B R I

The Microcontroller Idea Book:

Circuiti, programmi ed applicazioni sviluppate con il microcontrollore 8052-BASIC Microcontrolle da Jan Axelson, (con paragrafi disponibili in linea).


Il componente 80C52-BASIC e' un microcontrollore 80C52 mascherato con un completo interprete BASIC-52 che risiede negli 8K byte di ROM interna. L'80C52-BASIC e' appositamente progettato per soddisfare le esigenze di controllo di processo, misura ed applicazioni di acquisizione. Il linguaggio interno BASIC-52 consente all'utente di scrivere direttamente in BASIC mentre del codice in linguaggio assembly e' facilmente eseguibile come CALL a procedure, sempre dal BASIC.

Il disegno completamente statico del microprocessore 80C52-BASIC consente all'utente di ridurre il consumo abbassando la frequenza di clock dai 29 MHz fino ad ogni valore, anche DC, senza perdita di dati o dei valori dei registri interni (la frequenza tipica per il BASIC-52 e' di 11,0592 o 22,1184 MHz). In aggiunta, l'80C52 ha due diversi modi operativi software per ridurre l'attivita': modalita' Idle, dove la CPU e' congelata ma i timers, port ed interrupt continuano a funzionare; modalita' Power Down, dove la RAM interna e' mantenuta ma tutte le altre funzioni sono fermate.

Una minima quantita' di hardware e' necessaria per utilizzare il microcontrollore 80C52-BASIC. Dei sistemi minimi possono essere costruiti solo con un latch per gli indirizzi, 1K byte di memoria esterna e gli appositi driver per la seriale. Con l'aggiunta di un transistor, una porta e pochi componenti passivi, il BASIC-52 puo' programmare direttamente anche EPROM ed EEPROM. Sono supportati sia gli algoritmi di programmazione standard che quelli veloci.

Electric Diagram

Software

 

Hardware


Interprete BASIC-52

Il BASIC-52 e' una completa implementazione di un linguaggio BASIC in soli 8K bytes di ROM. E' un potente strumento che combina la facilita' di sviluppo di un linguaggio ad alto livello, con la velocita' necessaria per la maggioranza dei controlli di processo. Grazie al minimo uso di istruzioni di sistema ed alla frequenza di clock da 11 MHz o superiore, il BASIC-52 e' estremamente veloce ed efficiente. Attualmente esegue il famoso programma di benchmark "sieve" piu' velocemente di un P.C. XT. Il BASIC-52 offre alcune caratteristiche uniche, come un preciso orologio in tempo reale, la possibilita' di gestire interrupt, un facile utilizzo delle periferiche hardware e la possibilita' di gestire EPROM o EEPROM come dispositivi di memoria di massa. In aggiunta, molte delle procedure interne del BASIC (I/O, aritmetiche, trasformazione, ecc.) possono essere chiamate come sottoprocedure assembly.

Il BASIC-52 consente di usare sia numeri interi che in virgola mobile. I numeri interi variano da 0 a 65536 mentre quelli in virgola mobile variano da +-1E-127 a +-0,99999999E+127 con otto cifre significative. I numeri possono essere inseriti e visualizzati nei formati interi, decimale, esadecimale ed esponenziale.

Segue una lista di comandi, istruzioni ed operatori disponibili nell'80C52-BASIC. Anche se alcune di queste sono caratteristiche del BASIC-52, una veloce ispezione illustra la disponibilita' di tutto quanto e' normalmente necessario per la programmazione strutturata e per lo sviluppo di complete applicazioni di controllo processo.

COMMANDS

STATEMENTS

OPERATORS

RUN BAUD FOR-TO-STEP PRINT# + PI XBY()
LIST CALL NEXT PH0. - SIN() GET
LIST # CLEAR GOSUB PH0.# * COS() IE
NEW CLEARS RETURN PH1. / TAN() IP
NULL CLEAR1 GOTO PH1.# ** ATN() PORT1
RAM CLOCK0 ON-GOTO PUSH .AND. = PCON
ROM CLOCK1 ON-GOSUB POP .OR. < RCAP2
XFER DATA IF-THEN-ELSE PWM .XOR. <= T2CON
PROG READ INPUT REM NOT > TCON
PROG1 RESTORE LET RETI ABS() >= TMOD
PROG2 DIM ONERR STOP INT() <> TIME
FPROG DO-WHILE ONEXT1 STRING SGN() ASC() TIMER0
FPROG1 DO-UNTIL ONTIME UO0 SQR() CHR() TIMER1
FPROG2 END PRINT UO1 RND CBY() TIMER2
      UI0 LOG() DBY() XTAL
      UI1 EXP()   MTOP

Operating Conditions*

Operating Temperature:
Commercial 0 C to 70 C
Industrial -40 C to 85 C
Operating voltage (Vcc): +5 volts
± 10%

Absolute Maximum Ratings*

Voltage on any pin with respect to ground (Vss): -0.5V to 7.0V
Power dissipation: 200 mW
Maximum lcc at 12 MHz: 24mA


BASIC Chips

80C52-BASIC Pin Description*

Vss – Circuit ground potential

Vcc – Circuit supply voltage

AD0-AD7 – The multiplexed low-order address and data bus used during access to external memory. External pull-up resistors (10k ohm) are required on these pins if BASIC-52 EPROM/EEPROM programming feature is used.

A8-A15 – The high-order address bus used during access to external memory.

PORT 1 – Port 1 is a quasi-bidirectional 8-bit input/output port. It can be used as a standard parallel I/O port with the PORT1 command in BASIC-52, or the individual pins of Port 1 can have alternative functions as follows:

PORT 1.0(T2) – Can be used as the trigger input to Timer/Counter #2. A logic 1 must be written to this bit in order for this function to operate.

PORT 1.1 (T2EX) – Can be used as the external input to Timer/Counter #2. A logic 1 must be written to this bit in order for this function to operate.

PORT 1.2 (PWM OUTPUT) – This pin is used as the Pulse Width Modulated (PWM) output port when the PWM statement is executed. The PWM statement can generate pulses of varying frequency and duty cycle.

PORT 1.3 (ALE DISABLE) – This pin is used to disable the ALE signal to the external latch when the EPROM/EEPROM programming feature is being used. In a system, this pin is logically ANDed with ALE.

PORT 1.4 (PROGRAMMING PULSE) – This pin provides the proper programming pulse when programming EPROM/EEPROMs.

PORT 1.5 (PROGRAMMING ENABLE) – This pin is used to enable the programming voltage (Vpp) when programming EPROMs and remains active low during programming. On EEPROMs that do not require any special programming voltage, this pin is not used.

PORT 1.6 (DMA ACKNOWLEDGE) – When the pseudo-DMA feature is implemented (as outlined in the BASIC-52 Programmer’s Manual), this pin functions as an active-low DMA Acknowledge output.

PORT 1.7 (LINE PRINTER OUTPUT) – This pin functions as a serial output when the LIST# or PRINT# commands are used in BASIC. This enables the user to have hard-copy output during program operation or for program listings.

RESET – A logic 1 (>3.5V) on this pin for more than two machine cycles while the oscillator is running will reset the device. An internal pull-down resistor permits power-on reset using only a capacitor connected between this pin and Vcc.

ALE – (Address Latch Enable) an output pin that is used to latch the low-order address byte during read, write, or program fetch operations to external memory.

PSEN – (Program Store Enable) a signal used to enable external program memory. This pin will remain a logic 1 unless the user is running an assembly language program in external memory.

XTAL1 – Input to the inverting amplifier that forms the oscillator. This input should be left floating when an external oscillator is used.

XTAL2 – Output of the inverting amplifier that forms the oscillator and input to the internal clock generator. Receives the external oscillator signal when an external oscillator is used.

RD – This pin is a control that is used to enable read operations to external data memory.

WR – This pin is a control signal that is used to enable write operations to external data memory.

T1 – This pin can be programmed to be an external input to Timer/Counter 1

T0 – This pin can be programmed to be an external input to Timer/Counter 0

INT1 – This is the external interrupt 1 input pin. Interrupts on this pin may be handled in either BASIC-52 or assembly language.

INT0/DMA REQUEST – This is the external interrupt 0 input pin. It may optionally be programmed to function as a DMA request input pin or used by EEPROM devices during programming.

CONSOLE SERIAL OUTPUT – This is the serial input pin that receives data from the console device. Standard serial ASCII codes consisting of 8-bit data with no parity at standard data rates are assumed. After RESET in BASIC-52, if desired and if the first character received is a "space," then BASIC-52 will perform an auto-baudrate calculation and automatically set the console serial input to the incoming data rate.

EA – When EA is held high, the CPU functions as an 80C52 with a BASIC interpreter executing out of internal program memory (unless the program counter exceeds 0FFFh). When EA is held low, the CPU functions as a generic 80C52 and executes only out of external program memory.

*Note: For complete details of the 80C52-BASIC chip’s electrical characteristics and timing diagrams, refer to the design specification sheet for the 80C52 microcontroller chip.



COMMAND FUNCTION


RUN Execute a program
CONT CONTinue after a STOP or control-C
LIST LIST program to the console device
LIST# LIST program to serial printer port (P1.7)
NEW Erase the program stored in RAM
NULL Set NULL count after carriage return/line feed
RAM Evoke RAM mode, current program in READ/WRITE memory
ROM Evoke ROM mode, current program in ROM/EPROM memory
XFER Transfer a program from ROM/EPROM to RAM



STATEMENT FUNCTION

BAUD Set baud rate for line printer port
CALL CALL assembly language program
CLEAR CLEAR variables, interrupts and Strings
CLEARS CLEAR Stacks
CLEARI CLEAR Interrupts
CLOCK1 Enable REAL TIME CLOCK
CLOCK0 Disable REAL TIME CLOCK
DATA DATA to be read by READ statement
READ READ data in DATA statement
RESTORE RESTORE READ pointer
DIM Allocate memory for arrayed variables
DO Set up loop for WHILE or UNTIL
UNTIL Test DO loop condition (loop if false)
WHILE Test DO loop condition (loop if true)
END Terminate program execution
FOR-TO-{STEP} Set up FOR-NEXT loop
NEXT Test FOR-NEXT loop condition
GOSUB Execute subroutine
RETURN RETURN from subroutine
GOTO GOTO program line number
ON GOTO Conditional GOTO
ON GOSUB Conditional GOSUB
IF-THEN-{ELSE} Conditional test
INPUT INPUT a string or variable
LET Assign a variable or string a value (LET is optional)
ONERR ONERRor GOTO line number
ONTIME Generate an interrupt when TIME is equal to or greater than
ONTIME argument-line number is after comma
ONEX1 GOSUB to line number following ONEX1 when INT1 pin is pulled
low
PRINT PRINT variables, strings or literals P. is shorthand for PRINT
PRINT# PRINT to software serial port (P1.7)
PH0. PRINT HEX mode with zero suppression
PH1. PRINT HEX mode with no zero suppression
PH0.# PH0. to line printer (P1.7)
PH1.# PH1.# to line printer (P1.7)
PUSH PUSH expressions on argument stack
POP POP argument stack to variables
PWM PULSE WIDTH MODULATION
REM REMark
RETI RETurn from Interrupt
STOP Break program execution
STRING Allocate memory for STRlNGs
UI1 Evoke User console Input routine
UI0 Evoke BASIC console Input routine
UO1 Evoke User console Output routine
UO0 Evoke BASIC console Output routine


OPERATORS FUNCTION

CBY( ) Read program memory
DBY( ) Read/assign internal data memory
XBY( ) Read/assign external Data memory
GET Read console
IE Read/assign IE register
IP Read/assign IP register
PORT1 Read/assign I/O port 1 (P1)
PCON Read/assign PCON register
RCAP2 Read/assign RCAP2 (RCAP2H:RCAP2L)
T2CON Read/assign T2CON register
TCON Read/assign TCON register
TMOD Read/assign TMOD register
TIME Read/assign the REAL TIME CLOCK
TIMER0 Read/assign TIMER0 (TH0: TL0)
TIMER1 Read/assign TIMER1 (TH1: TL1)
TIMER2 Read/assign TIMER2 (TH2: TL2)
+ Addition
/ Division
** Exponentation
* Multiplication
- Subtraction
.AND. Logical AND
.OR. Logical OR
.XOR. Logical XOR


STORED CONSTANT

PI Pi - 3.1415926


OPERATORS - SINGLE OPERAND

ABS( ) Absolute value
NOT( ) Ones complement
INT( ) Integer
SGN( ) Sign
SQR( ) Square root
RND Random number
LOG( ) Natural log
EXP( ) "e" (2.7182818) to the X
SIN( ) Returns the sine of argument
COS( ) Returns the cosine of argument
TAN( ) Returns the tangent of argument
ATN( ) Returns arctangent of argument


Pagina aggiornata al 23 Ottobre 2004


home Home Software Linguaggi BXC51 GET51