Interactive Powerpoint_How to Master effective communication
Class 6 an 8 bit embedded platform -pic mircocontroller basics
1. An 8 Bit Embedded
Platform (Part II)
Session 6
SURYAPRAKASH S
suryaprakash.vsm@gmail.com
The resource for the PPT is made from variety of Books and online
PPT that were available in Internet. The Purpose of the PPT is made
for the Classroom Teaching.
3. Introduction
• There are three memory blocks
in each of the PIC16F87XA
devices
• The program memory and data
memory have separate buses so
that concurrent access can
occur. ( due to Harvard
Architecture).
12-02-2019 suryaprakash.vsm@gmail.com 3
4. Program Memory Organization
• The PIC16F876A/877A devices have 8K
words x 14 bits of Flash program
memory, accessing a location above the
physically implemented address will
cause a wraparound.
• The Reset vector is at 0000h and the
interrupt vector is at 0004h.
12-02-2019 suryaprakash.vsm@gmail.com 4
5. Data Memory Organization
• The data memory is partitioned into multiple banks which contain the
General Purpose Registers and the Special Function Registers.
• Bits RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits.
12-02-2019 suryaprakash.vsm@gmail.com 5
6. Contd.,
• Each bank extends up to 7Fh (128 bytes). The lower locations of each
bank are reserved for the Special Function Registers.
• Above the Special Function Registers are General Purpose Registers,
implemented as static RAM.
• Some frequently used Special Function Registers from one bank may
be mirrored in another bank for code reduction and quicker access.
• GPR file can be accessed either directly, or indirectly, through the File
Select Register (FSR).
• Image
12-02-2019 suryaprakash.vsm@gmail.com 6
7. SPECIAL FUNCTION REGISTERS
• The Special Function Registers are registers used by the CPU and
peripheral modules for controlling the desired operation of the
device.
• These registers are implemented as static RAM.
• The Special Function Registers can be classified into two sets: core
(CPU) and peripheral.
• Link to Special Function Register
12-02-2019 suryaprakash.vsm@gmail.com 7
8. Status Register
• The Status register contains the arithmetic status of the ALU, the Reset status and
the bank select bits for data memory.
• The Status register can be the destination for any instruction, as with any other
register.
• If the Status register is the destination for an instruction that affects the Z, DC or
C bits, then the write to these three bits is disabled.
• These bits are set or cleared according to the device logic. Furthermore, the TO
and PD bits are not writable, therefore, the result of an instruction with the
Status register as destination may be different than intended.
• For example, CLRF STATUS, will clear the upper three bits and set the Z bit. This
leaves the Status register as 000u u1uu (where u = unchanged).
• It is recommended, therefore, that only BCF, BSF, SWAPF and MOVWF
instructions are used to alter the Status register because these instructions do
not affect the Z, C or DC bits from the Status register.
12-02-2019 suryaprakash.vsm@gmail.com 8
9. PCL and PCLATH
• The Program Counter (PC) is 13 bits wide. The low byte comes from the PCL register which is a
readable and writable register. The upper bits (PC<12:8>) are not readable, but are indirectly
writable through the PCLATH register. On any Reset, the upper bits of the PC will be cleared.
12-02-2019 suryaprakash.vsm@gmail.com 9
10. STACK
• The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack.
• The stack space is not part of either program or data space and the stack
pointer is not readable or writable.
• The PC is PUSHed onto the stack when a CALL instruction is executed, or an
interrupt causes a branch.
• The stack is POP’ed in the event of a RETURN, RETLW or a RETFIE
instruction execution.
• The stack operates as a circular buffer. This means that after the stack has
been PUSHed eight times, the ninth push overwrites the value that was
stored from the first push. The tenth push overwrites the second push (and
so on).
12-02-2019 suryaprakash.vsm@gmail.com 10
11. Program Memory Paging
• All PIC16F87XA devices are capable of addressing a continuous 8K word
block of program memory.
• The CALL and GOTO instructions provide only 11 bits of address to allow
branching within any 2K program memory page.
• When doing a CALL or GOTO instruction, the user must ensure that the
page select bits are programmed so that the desired program memory
page is addressed.
• If a return from a CALL instruction (or interrupt) is executed, the entire 13-
bit PC is popped off the stack.
• Therefore, manipulation of the PCLATH<4:3> bits is not required for the
RETURN instructions (which POPs the address from the stack).
12-02-2019 suryaprakash.vsm@gmail.com 11
12. Example 2-1 shows the calling of a subroutine in page 1 of the program
memory. This example assumes that PCLATH is saved and restored by
the Interrupt Service Routine (if interrupts are used).
12-02-2019 suryaprakash.vsm@gmail.com 12
13. DATA EEPROM AND FLASH PROGRAM MEMORY
• The data EEPROM and Flash program memory is readable and
writable during normal operation (over the full VDD range).
• This memory is not directly mapped in the register file space. Instead,
it is indirectly addressed through the Special Function Registers.
• There are six SFRs used to read and write this memory:
• EECON1
• EECON2
• EEDATA
• EEDATH
• EEADR
• EEADRH
12-02-2019 suryaprakash.vsm@gmail.com 13
14. Contd.,
• When interfacing to the data memory block, EEDATA holds the 8-bit
data for read/write and EEADR holds the address of the EEPROM
location being accessed. These devices have 128 or 256 bytes of data
EEPROM (depending on the device), with an address range from 00h
to FFh. On devices with 128 bytes, addresses from 80h to FFh are
unimplemented and will wraparound to the beginning of data
EEPROM memory.
• When interfacing the program memory block, the EEDATA and
EEDATH registers form a two-byte word that holds the 14-bit data for
read/write and the EEADR and EEADRH registers form a two-byte
word that holds the 13-bit address of the program memory location
being accessed. These devices have 4 or 8K words of program Flash,
with an address range from 0000h to 1FFFh for the PIC16F877A.
12-02-2019 suryaprakash.vsm@gmail.com 14
15. Contd.,
• The EEPROM data memory allows single-byte read and write. The Flash
program memory allows single-word reads and four-word block writes.
• Program memory write operations automatically perform an erase-before
write on blocks of four words.
• A byte write in data EEPROM memory automatically erases the location
and writes the new data (erase-before-write).
• The write time is controlled by an on-chip timer. The write/erase voltages
are generated by an on-chip charge pump, rated to operate over the
voltage range of the device for byte or word operations
12-02-2019 suryaprakash.vsm@gmail.com 15
16. 2/12/2019 suryaprakash.vsm@gmail.com 16
This Photo by Unknown Author is licensed under CC BY-NC-ND
Learn by Doing
Excel Thru Experimentation
Lead by Example
Acquire skills and get employed
Update skills and stay employed
Hinweis der Redaktion
A stack pointer is a small register that stores the address of the last program request in a stack. A stack is a specialized buffer which stores data...
A program counter is a register in a computer processor that contains the address (location) of the instruction being executed at the current time. As each instruction gets fetched, the program counter increases its stored value by 1. After each instruction is fetched, the program counter points to the next instruction in the sequence. When the computer restarts or is reset, the program counter normally reverts to 0.