What you will need to program microcontroller
In the
late 1970s and early 1980s, the cost of equipment for developing
microcontroller-based systems was beyond the reach of most small
companies. Now, however, there are many high school students already
developing exciting PIC projects.
To get started you will need the following equipment and documentation:
• One or more PIC16C84s or PIC16F84s (the ’83 devices will also suffice)
• A Personal Computer running Windows 3.1 or Windows ’95.
• A copy of the latest MPLAB software available free of charge from Microchip Technology Inc.
• PIC microcontroller data sheets and application notes available free of charge from Microchip Technology Inc.
• A PICStart-Plus programmer. Programmers available from third party manufacturerswhich support the PIC devices will also be suitable.
• A circuit breadboard or similar means of circuit construction.
• A 5V DC power supply.
• Some light emitting diodes (LEDs), resistors and some 32kHz crystals.
• Test equipment such as a digital multimeter and an oscilloscope (not essential).
To get started you will need the following equipment and documentation:
• One or more PIC16C84s or PIC16F84s (the ’83 devices will also suffice)
• A Personal Computer running Windows 3.1 or Windows ’95.
• A copy of the latest MPLAB software available free of charge from Microchip Technology Inc.
• PIC microcontroller data sheets and application notes available free of charge from Microchip Technology Inc.
• A PICStart-Plus programmer. Programmers available from third party manufacturerswhich support the PIC devices will also be suitable.
• A circuit breadboard or similar means of circuit construction.
• A 5V DC power supply.
• Some light emitting diodes (LEDs), resistors and some 32kHz crystals.
• Test equipment such as a digital multimeter and an oscilloscope (not essential).
What makes a microcontroller useful?
PIC microcontroller |
A
microcontroller (or microprocessor) can be viewed as a set of digital
logic circuits integrated on a single silicon ‘chip’ whose connections
and behaviour can be specified and later altered when required, by the
program in its memory. The great advantage of this, is that in order to
change the circuit’s structure and operation, all that is needed is a
change in the program – very little, if any, circuit hardware
modifications are necessary. An alternative view is that a
microcontroller is a state machine whose logic states are defined by its
program. A microprocessor is the Central Processing Unit (CPU) of a
computer and a microcontroller can be regarded as a microprocessor
designed specifically for use in applications where machines such as
automobile engines or washing machines are to be controlled. Often the
distinction between microprocessors and microcontrollers is quite
blurred, as there is considerable overlap these days in the
classification of different types of computing devices. A typical
microprocessor is a device used in workstation computers, whereas a
microcontroller is usually less powerful and has special features such
as PWM (pulse width modulation) and timer devices integrated on the IC
specifically for use in the applications mentioned above.
Simplified operation of a microcontroller
Humans
perform arithmetic using a decimal or base ten numbering system.
Computers use a base two system with the digits 0 and 1 and, because
there are only two possibilities, they are termed binary digits or bits
for short. There are many ways of representing a binary set of states,
for example
• a mechanical or electronic switch with two states — on or off
• opposite directions of current or fluid flow
• two different pressures
• a positive and a zero voltage.
• a mechanical or electronic switch with two states — on or off
• opposite directions of current or fluid flow
• two different pressures
• a positive and a zero voltage.
In
digital electronic circuits, the last choice is the most natural.
Circuits implemented using TTL (Transistor-Transistor Logic) technology
use 5V to represent the binary value 1 and a zero voltage to represent
0. The circuits discussed in this book, although not TTL circuits, will
use the approximately the same representation. To provide some
robustness to the representation, voltages above 3.5V will be taken to
represent a logical 1 and those below 1.5V to represent a logical 0.
Readers new to the subject of digital electronics are urged to consult
one of the many excellent books available on the subject,
A simple microcontroller consists of the following modules:
A simple microcontroller consists of the following modules:
• An Arithmetic Logic Unit (ALU)
• One or more working registers (called accumulators in the past) for temporary storage during computations. A register is a small block of memory, often the size of a byte, where data is stored.
• Program memory (ROM) and data memory (RAM).
• A program counter.
• An instruction register with instruction decoder.
• The control unit.
• A stack.
• One or more working registers (called accumulators in the past) for temporary storage during computations. A register is a small block of memory, often the size of a byte, where data is stored.
• Program memory (ROM) and data memory (RAM).
• A program counter.
• An instruction register with instruction decoder.
• The control unit.
• A stack.
The ALU
is responsible for performing all arithmetic operations such as
addition, subtraction and Boolean logical operations, including
exclusive-or and bit shifting. Multiplication and division is usually
accomplished by repeated use of addition or subtraction, but some
devices (such as the PIC17CXX series) have hardware multipliers. The
working registers are used by the ALU as temporary ‘scratchpad’ memory,
for example, for holding intermediate results of arithmetic operations.
A program is a set of sequential operations on data. The program
memory is an area of memory where the actual sequence of instructions
which make up the program is stored. Data memory is an area of memory
where data such as the value of constants are kept for use by the
program during its execution. The program counter is a register used to
store the address of the next instruction to be executed. Because the
program consists of instructions stored sequentially in program memory,
the address of the next instruction is obtained by simply incrementing
the number (that is, the address), contained in the program counter.
The
instruction register contains the actual binary instruction that needs
to be executed. The instruction decoder takes the binary instruction and
decodes it to determine what operation the instruction must perform and
which data it must use. The control unit controls the timing and
sequencing of all operations necessary to correctly schedule and execute
instructions. While an instruction is executing, the next instruction
is fetched from the program memory and placed in the instruction
register with help from the program counter. The instruction decoder
then decodes the instruction and it is executed when the next execute
cycle occurs.
The
stack is an area of memory used to keep track of the contents of the
program counter when subroutines are called. When data is written to the
stack, it is stored at the ‘top’ of the stack. This operation is
referred to as pushing data onto the stack. When data is removed from
the top of the stack, the stack is said to be popped. A subroutine is a
block of program code that performs a calculation or operation that the
main program needs to do a number of times. Instead of repeatedly
inserting the block of code at each position in the main program where
it is needed, the subroutine is called when required. When a subroutine
is called, the return address (that is, the address of the next
instruction that must be executed when the subroutine terminates), is
pushed onto the top of the stack. In other words, the program counter is
first incremented to specify the address of the next instruction to be
executed after subroutine completion and then its contents are pushed
onto the stack. The address of the beginning of the subroutine is then
loaded into the program counter so that it can be executed. When
subroutine execution is complete, the top of the stack is popped and the
address of the next instruction is loaded into the program counter
again, so that the program can continue where it left off before the
subroutine was called.
No comments:
Post a Comment