Professional Documents
Culture Documents
Chapter 1
A VERY BRIEF HISTORY OF MICROPROCESSORS & MICROCONTROLLERS
05-Apr-11
05-Apr-11
05-Apr-11
05-Apr-11
A generic microcontroller
10
05-Apr-11
11
Advantages of PIC
It is a RISC (Reduced Instruction Set Computer) design Only thirty seven instructions to remember Its code is extremely efficient, allowing the PIC to run with typically less program memory than its larger competitors. It is low cost, high clock speed
12
05-Apr-11
Harvard Architecture
13
Von-Neumann Architecture
14
05-Apr-11
15
16
05-Apr-11
17
18
05-Apr-11
19
20
10
05-Apr-11
21
22
11
05-Apr-11
23
24
12
05-Apr-11
25
26
13
05-Apr-11
27
28
14
05-Apr-11
29
30
15
05-Apr-11
Block diagram of the 16F84A (supplementary labels in shaded boxes added by the author)
31
W Register
32
16
05-Apr-11
33
Unlike most MCUs, there are no instructions to specifically clear or set a flag, such as sec for SEt Carry (MC6800). However, as the Status register is accessible as a file in the Data store, then any instruction that can alter the contents of a file can potentially change the state of a flag.
34
17
05-Apr-11
35
36
18
05-Apr-11
37
38
19
05-Apr-11
39
Data EEPROM
The PIC16F84 has a blockof 64 bytes of data that does not require power to retain its contents. This non-volatile memory is not part of the (volatile) Data store and is accessed through SPRs as a peripheral device. Any byte can be addressed and then read from or written to via the EEDATA register as addressed by the EEADR register and controlled by the EECON1 and EECON2 control file registers. Data EEPROM has a minimum endurance of 1,000,000 writes and such data is retained for upwards of 40 years. Some typical uses of a non-volatile depository would be to hold the number of pages printed in a laser printer or total miles/kilometers travelled in a car. 40
20
05-Apr-11
EEPROM
To read an EEPROM location, the required address must be placed in EEADR and the RD bit set in EECON1. The data in that memory location is then copied to the EEDATA register and can be read immediately. To write to an EEPROM location, the required data and address must be placed in EEDATA and EEADR respectively. The write process is enabled by the WREN (Write Enable) bit being set high, followed by the bytes 55H followed by AAH being sent to the EECON2 register. The built-in requirement for these codes helps to ensure that accidental writes do not take place, for example on power-up or down. The WR bit is then set high and writing actually commences. The write completion is signalled by the setting of bit EEIF in EECON1.
41
42
21
05-Apr-11
43
44
22
05-Apr-11
45
Pipelining
The combination of the RISC instruction set and the Harvard memory map used by PIC microcontrollers has an added advantage: instructions can be pipelined. Every instruction in a computers program memory has first to be fetched and then executed. In many CPUs these two steps are done one after the other first the CPU fetches and then it executes. If, however, program memory has its own address and data bus, separate from data memory (i.e. a Harvard structure), then there is no reason why a CPU cannot be designed so that while it is executing one instruction, it is already fetching the next. This is called pipelining.
46
23
05-Apr-11
In the 16F84A there is a Reset input, MCLR (Master Clear, on pin 4). As long as this is held low, the microcontroller is held in Reset. When it is taken high, program execution starts. If the pin is taken low while the program is running, then program execution stops immediately and the microcontroller is forced back into Reset mode.
47
The last one is only for a PIC that is not powering an LED or other high-current load.
48
24
05-Apr-11
49
Addressing Modes
50
25
05-Apr-11
DIRECT/INDIRECT ADDRESSING
51
52
26
05-Apr-11
53
54
27
05-Apr-11
55
PIC18Fxx2 MCU
56
28
05-Apr-11
57
58
29
05-Apr-11
59
60
30
05-Apr-11
61
62
31
05-Apr-11
63
32
05-Apr-11
65
66
33
05-Apr-11
68
34
05-Apr-11
69
70
35