Download presentation
Presentation is loading. Please wait.
1
EE 22442 - Embedded Systems Fall 2015
Chapter Seven: Larger Systems and the PIC 16F873A/ 16F874A/ 16F877A EE Embedded Systems Fall 2015 Belal H. Sababha, Ph.D. Assistant Professor of Electrical & Computer Engineering Computer Engineering Department King Abdullah II Faculty of Engineering Princess Sumaya University for Technology Amman, 11941, Jordan Phone: ext. 222 Web:
2
Introduction A microcontroller is essentially made up of: Microprocessor core plus memory plus peripherals More ‘power’ can be added to a microcontroller by enhancing any of these areas. As the 16F84A and 16F873A are both members of the same family, the core and instruction set remain constant, but the ability to engage in embedded control is dramatically enhanced by the addition of an excellent range of ‘new’ peripherals.
3
The main idea – the PIC 16F87XA
5
The 16F873A block diagram and CPU
Overview of the Central Processing Unit and core Overview of memory The 13 program address lines from the Program Counter, which can address 2^13 (i.e. 8192) memory locations, are now fully exploited in the 16F876A with its 8K of program memory, and half used in the ’873A. One bus size which has changed is the ‘Direct Addr’, shown here as seven bits Overview of peripherals
6
16F873A Status Register
7
16F873A memory and memory maps
The 16F873A program memory The 13-bit Program Counter word is able to address the whole memory space. It is surprising to see in the figure that there are two ‘pages’ of program memory. The situation is worse for the 16F876A/877A controllers, each has four pages of program memory. The fact that program memory has to be paged in this way is due to the way the program address, held in the Program Counter, is generated in different situations.
8
Program Counter The Program Counter is 13 bits long.
Its lower 8 bits form the PCL register. The upper five bits of the Program Counter are not readable, but can be written to via the lower five bits of the PCLATH register. The contents of PCLATH are transferred to the upper bits of the Program Counter whenever PCL is written to. In normal program execution, the Program Counter is incremented after every instruction. However, there are three other ways by which the program can change the Program Counter value.
9
Manipulating the Program Counter
10
Manipulating the Program Counter .. cntd
1. By Stack transfers 2. By call and goto instructions These two instructions are formatted to provide only 11 bits of addressing. These 11 bits can address a range of 2^11, or 2K words, and thus represent the pages in Figure 7.4. When these instructions are used, the two ‘missing’ address bits are taken from bits 4 and 3 of the PCLATH register. It is up to the programmer to recognize if a branch over a page is to occur, and to set the bits appropriately. The data sheet [Ref. 7.1] contains an example of how to do this. 3. By writing to the PCL register The PCL is written to directly in situations like the ‘computed go to’, as described in Section 5.4. Now only the lower eight bits of the Program Counter, in PCL, are adjusted directly and it is as if the programmer is working with 256-word pages. If an address boundary is to be crossed in a computed go to, then PCLATH must be set to the right value. For larger look-up tables this can be quite challenging; Ref. 5.1 gives examples of how to do it.
11
The 16F873A data memory and Special Function Registers
12
The 16F873A interrupts
13
The interrupt registers
Figure 7.11: The PIC 16F87XA INTCON register
14
The interrupt registers … cnt’d
15
The interrupt registers … cnt’d
16
The 16F873A parallel ports The PIC 16F873A has three ports, A, B and C. Ports A and B are similar to the ports of the 16F84A, except that more alternate functions are crowded onto the pins. Port A is now 6-bit, a 1-bit advance on the five bits of the 16F84A Port A.
17
The 16F873A Port A The six bits of Port A appear on pins 2–7 of the 16F873A The port can be used for general-purpose bi-directional digital data. It is also shared with the Analog functions, notably the analog-to-digital converter (ADC) module and the comparators. On powerup the port bits are set as analog inputs. To use the port for digital purposes the ADCON1 register, described in Chapter 11, must be set appropriately. As with the 16F84A, the important Timer 0 input is on bit 4 of Port A.
18
The 16F873A Port A … cnt’d The port pins are no longer simply controlled by the port ‘TRIS’ register. Other SFRs can have a major impact, disabling or reallocating a resource. This can lead to considerable programming frustration. A port may appear not to work because a peripheral SFR setting has reallocated its function.
20
16F873A Port B and PORT C The 16F873A Port B: same as 16F84A
The 16F873A Port C: The Port C interconnection can be seen on pins 11–18 of the 16F873A (Figure 7.1). It is the most complex of the 16F873A ports. Its pins can simply be used as general-purpose digital input/output (I/O). Port C pins are shared with some of the more complex microcontroller peripherals, including those dealing with serial communication.
22
The challenge of testing an embedded system
23
Test and diagnostic tools
Oscilloscopes and logic analyzers In-circuit emulators On-chip debuggers
24
Taking things further – the 16F874A/16F877A Ports D and E
The 16F874A and 16F877A have two extra ports. The 8-bit Port D and the 3-bit Port E. Either port can be used for general-purpose I/O, like any of the other ports. An alternative function for Port E is to provide three further analog inputs. Because of this, Port E is also under the control of one of the registers that control the ADC, ADCON1. The setting of this determines whether the port is used for digital or analog signals.
26
Figure 7.26: The TRISE register
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.