PIC16F870T-I/SS Microchip Technology, PIC16F870T-I/SS Datasheet - Page 32

IC MCU FLASH 2KX14 EE 28SSOP

PIC16F870T-I/SS

Manufacturer Part Number
PIC16F870T-I/SS
Description
IC MCU FLASH 2KX14 EE 28SSOP
Manufacturer
Microchip Technology
Series
PIC® 16Fr

Specifications of PIC16F870T-I/SS

Core Processor
PIC
Core Size
8-Bit
Speed
20MHz
Connectivity
UART/USART
Peripherals
Brown-out Detect/Reset, POR, PWM, WDT
Number Of I /o
22
Program Memory Size
3.5KB (2K x 14)
Program Memory Type
FLASH
Eeprom Size
64 x 8
Ram Size
128 x 8
Voltage - Supply (vcc/vdd)
4 V ~ 5.5 V
Data Converters
A/D 5x10b
Oscillator Type
External
Operating Temperature
-40°C ~ 85°C
Package / Case
28-SSOP
For Use With
I3-DB16F871 - BOARD DAUGHTER ICEPIC3
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
PIC16F870/871
3.5
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 and insert the value into the EEDATH:EEDATA
registers. Data will be available following the second
NOP instruction. EEDATH and EEDATA will hold their
value until another read operation is initiated, or until
they are written by firmware.
The steps to reading the FLASH program memory are:
1.
2.
3.
4.
5.
EXAMPLE 3-3:
DS30569B-page 30
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
memory size of the PIC16F870/871 devices.
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
microcontroller 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
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
;
3.6
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 3-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
memory size of the PIC16F870/871 devices.
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
microcontroller 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
 2003 Microchip Technology Inc.

Related parts for PIC16F870T-I/SS