Page 235 - Mechatronics with Experiments
P. 235
MICROCONTROLLERS 221
the program starts is called the temporary data, and is stored in the RAM. When power is
turned OFF, information in the RAM is lost. The exception to this is battery backed-RAM,
where the data is not lost when power is turned OFF to the computer because the battery still
keeps the RAM powered. Flash memory has the characteristics of both ROM and RAM.
Flash memory is a type of EEPROM memory which is packaged as “flash-disk” or
“flash-stick” as a permanent data storage device, that is a solid-state permanent data store
device without any mechanically moving parts. It retains its content when power is turned
OFF, like a ROM, and it can be re-written, like a RAM. Read access time is in the order of
that of dynamic RAM. Erase and re-write time is significantly slower compared to RAM. It
offers random access read, but not random access write operations because it can be erased
and re-written in ”blocks.” Typically, flash memory can be used for about 100 000 re-write
cycles.
A microcontroller is a single-chip integrated circuit (IC) computer. PIC stands for
peripheral interface controller. PIC is a trade name given to a series of microcontrollers
manufactured by Microchip Technology Inc. We will be using the PIC 18F452 chip for the
laboratory experiments. The PIC 18F452 has five bidirectional input–output ports, named
Ports A to E. Port A is 7-bit wide port while Port E is 3-bits wide (Figure 4.6). The other
ports, B to D, are all 8-bit ports. Port pins are labeled RA0 through RA6, RB0 through RB7,
RC0 through RC7, RD0 through RD7, and RE0 through RE2. Hence, the total number of
pins at ports A through E is 7 + 8 + 8 + 8 + 3 = 34 out of a 40-pin DIP package of PIC
18F452 chip (Figure 4.6). The remaining pins are used for V (two pins), V (two pins),
DD SS
OSC1∕CLK1, MCLR∕V . Most of the pins are software configurable for one of multiple
PP
functions between general purpose I/O and peripheral I/O. Using registers in the chip, one
function is selected for each pin under software control.
The PIC 18F452 is an 8-bit microcontroller based on the Harvard architecture. It is
available in 40-pin DIP, 44-pin PLCC, and 44-pin TQFP packages. In the 44-pin packages,
4 of the pins are not used and labeled as NC. The Harvard architecture separates the program
memory and the data memory. During a single instruction cycle, both program instructions
MCLR/Vpp 1 40 RB7
RA0/AN0 2 39 RB6
RA1/AN1 3 38 RB5
RA2/AN2/Vref– 4 37 RB4
RA3/AN3/Vref+ 5 36 RB3/CCP2*
RA4/T0CKI 6 35 RB2/INT2
RA5/AN4/SS/LVDIN 7 34 RB1/INT1
RE0/RD/AN5 8 33 RB0/INT0
RE1/WR/AN6 9 32 Vdd
RE2/CS/AN7 10 PIC18F4×2 31 VSS
Vdd 11 30 RD7/PSP7
Vss 12 29 RD6/PSP6
OSC1/CLKI 13 28 RD5/PSP5
OSC2/CLKO/RA6 14 27 RD4/PSP4
RC0/T1OSO/T1CKI 15 26 RC7/RX/DT
RC1/T1OSI/CCP2* 16 25 RC6/TX/CK
RC2/CCP1 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0 19 22 RD3/PSP3
RD1/PSP1 20 21 RD2/PSP2
FIGURE 4.6: Pin diagrams of the PIC 18F452 microcontroller (DIP 40-pin model shown).