Page 231 - Mechatronics with Experiments
P. 231
MICROCONTROLLERS 217
contains the machine code (disassembled) generated for each line of the assembly and
C-code in a program. These files can be useful in the debugging process.
High level programming languages try to hide the processor specific details from
the programmer. This allows the programmer to program different microprocessors with
a single high level language. In microcontroller applications, it is generally necessary to
understand the hardware and assembly language capabilities of a particular microcontroller
in order to fully utilize its capabilities.
A computer program minimally needs the following machine instructions,
Access memory (and I/O devices), and perform read/write operations between the
CPU registers and the memory (and I/O devices). These operations are typically
called
LOAD address (read from address) and
STORE address (write to address).
Mathematical (add, subtract, multiply) and logical operations, such as
ADD address (implied to be added to the content of one the accumulators),
SUB address (implied to be subtracted from the content of one the accumulators),
AND, OR, NOT, JUMP, CALL, RETURN.
In high level languages, data structures (variables, structures, classes, etc.) are used to
manage the information. Assembly language does not provide data structures to manage
data in a program. It is up to the programmer to define variables and allocate proper memory
address space for them. Assembly language provides access instructions to the memory
and I/O devices as the source and destination for data. In addition it provides operators
(mathametical, logical, etc.) as well as various decision making instructions such as GOTO,
JUMP, CALL, RETURN. Using these instructions, we operate on the data in memory and
I/O devices.
The computer CPU accesses the resources (ROM, RAM, I/O devices) through a bus
which is the hardware connection between the components of a computer. The bus has four
basic groups of lines Figure 4.4:
1. power bus
2. control bus
3. address bus
4. data bus.
The power bus provides the power for the components to operate. Each line carries a
TTL level signal: 0 VDC or 5 VDC (OFF or ON). The control bus indicates whether the
CPU wants to read or write. The address bus selects a particular device or memory location
by specifying its address. The data bus carries the data between the devices. Notice that if
address bus is 16 lines (16-bit), there can be 2 16 = 65 536 distinct addresses the CPU can
access.
An I/O operation between the CPU and the memory (or I/O devices) involves the
following steps at the bus interface level:
the CPU places the address of the memory or I/O device on the address bus,
the CPU sets the appropriate control lines on the control bus to indicate whether it is
an input or output operation,