PIC16F877A-I/PT Microchip Technology Inc., PIC16F877A-I/PT Datasheet - Page 46

no-image

PIC16F877A-I/PT

Manufacturer Part Number
PIC16F877A-I/PT
Description
44 PIN, 7 KB FLASH, 368 RAM, 33 I/O
Manufacturer
Microchip Technology Inc.
Datasheet

Specifications of PIC16F877A-I/PT

A/d Inputs
8-Channel, 10-Bit
Comparators
2
Cpu Speed
5 MIPS
Eeprom Memory
256 Bytes
Input Output
33
Interface
I2C/SPI/USART
Memory Type
Flash
Number Of Bits
8
Package Type
44-pin TQFP
Programmable Memory
14K Bytes
Ram Size
368 Bytes
Speed
20 MHz
Timers
2-8-bit, 1-16-bit
Voltage, Range
2-5.5 V
Lead Free Status / Rohs Status
RoHS Compliant part Electrostatic Device

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC16F877A-I/PT
Manufacturer:
MICROCHIP
Quantity:
9 100
Part Number:
PIC16F877A-I/PT
Manufacturer:
AVAGO
Quantity:
84
Part Number:
PIC16F877A-I/PT
Manufacturer:
Microchip Technology
Quantity:
10 000
Part Number:
PIC16F877A-I/PT
Quantity:
1 639
Part Number:
PIC16F877A-I/PT
0
Company:
Part Number:
PIC16F877A-I/PT
Quantity:
3 000
PIC16F87X
4.4
Reading FLASH program memory is much like that of
EEPROM data memory, only two NOP instructions must
be inserted after the RD bit is set. These two instruction
cycles that the NOP instructions execute, will be used
by the microcontroller to read the data out of program
memory
EEDATH:EEDATA registers. Data will be available fol-
lowing the second NOP instruction. EEDATH and
EEDATA will hold their value until another read opera-
tion is initiated, or until they are written by firmware.
The steps to reading the FLASH program memory are:
1.
2.
3.
4.
5.
EXAMPLE 4-3:
DS30292C-page 44
BSF
BCF
MOVF
MOVWF
MOVF
MOVWF
BSF
BSF
BSF
NOP
NOP
BCF
MOVF
MOVWF
MOVF
MOVWF
Write the address to EEADRH:EEADR. Make
sure that the address is not larger than the mem-
ory size of the PIC16F87X device.
Set the EEPGD bit to point to FLASH program
memory.
Set the RD bit to start the read operation.
Execute two NOP instructions to allow the micro-
controller to read out of program memory.
Read the data from the EEDATH:EEDATA
registers.
Reading the FLASH Program
Memory
STATUS, RP1
STATUS, RP0
ADDRL, W
EEADR
ADDRH,W
EEADRH
STATUS, RP0
EECON1, EEPGD ;Point to Program memory
EECON1, RD
STATUS, RP0
EEDATA, W
DATAL
EEDATH,W
DATAH
and
insert
FLASH PROGRAM READ
;
;Bank 2
;Write the
;address bytes
;for the desired
;address to read
;Bank 3
;Start read operation
;Required two NOPs
;
;Bank 2
;DATAL = EEDATA
;
;DATAH = EEDATH
;
the
value
into
the
4.5
Writing to FLASH program memory is unique, in that
the microcontroller does not execute instructions while
programming is taking place. The oscillator continues
to run and all peripherals continue to operate and
queue interrupts, if enabled. Once the write operation
completes (specification D133), the processor begins
executing code from where it left off. The other impor-
tant difference when writing to FLASH program mem-
ory, is that the WRT configuration bit, when clear,
prevents any writes to program memory (see Table 4-1).
Just like EEPROM data memory, there are many steps
in writing to the FLASH program memory. Both address
and data values must be written to the SFRs. The
EEPGD bit must be set, and the WREN bit must be set
to enable writes. The WREN bit should be kept clear at
all times, except when writing to the FLASH Program
memory. The WR bit can only be set if the WREN bit
was set in a previous operation, i.e., they both cannot
be set in the same operation. The WREN bit should
then be cleared by firmware after the write. Clearing the
WREN bit before the write actually completes will not
terminate the write in progress.
Writes to program memory must also be prefaced with
a special sequence of instructions that prevent inad-
vertent write operations. This is a sequence of five
instructions that must be executed without interruption
for each byte written. These instructions must then be
followed by two NOP instructions to allow the microcon-
troller to setup for the write operation. Once the write is
complete, the execution of instructions starts with the
instruction after the second NOP.
The steps to write to program memory are:
1.
2.
3.
4.
5.
6.
7.
8.
9.
Write the address to EEADRH:EEADR. Make
sure that the address is not larger than the mem-
ory size of the PIC16F87X device.
Write the 14-bit data value to be programmed in
the EEDATH:EEDATA registers.
Set the EEPGD bit to point to FLASH program
memory.
Set the WREN bit to enable program operations.
Disable interrupts (if enabled).
Execute the special five instruction sequence:
• Write 55h to EECON2 in two steps (first to W,
• Write AAh to EECON2 in two steps (first to W,
• Set the WR bit
Execute two NOP instructions to allow the micro-
controller to setup for write operation.
Enable interrupts (if using interrupts).
Clear the WREN bit to disable program
operations.
then to EECON2)
then to EECON2)
Writing to the FLASH Program
Memory
2001 Microchip Technology Inc.

Related parts for PIC16F877A-I/PT