PIC18F45K20-I/ML Microchip Technology, PIC18F45K20-I/ML Datasheet - Page 67

IC PIC MCU FLASH 16KX16 44QFN

PIC18F45K20-I/ML

Manufacturer Part Number
PIC18F45K20-I/ML
Description
IC PIC MCU FLASH 16KX16 44QFN
Manufacturer
Microchip Technology
Series
PIC® XLP™ 18Fr

Specifications of PIC18F45K20-I/ML

Program Memory Type
FLASH
Program Memory Size
32KB (16K x 16)
Package / Case
44-QFN
Core Processor
PIC
Core Size
8-Bit
Speed
64MHz
Connectivity
I²C, SPI, UART/USART
Peripherals
Brown-out Detect/Reset, HLVD, POR, PWM, WDT
Number Of I /o
35
Eeprom Size
256 x 8
Ram Size
1.5K x 8
Voltage - Supply (vcc/vdd)
1.8 V ~ 3.6 V
Data Converters
A/D 14x10b
Oscillator Type
Internal
Operating Temperature
-40°C ~ 85°C
Processor Series
PIC18F
Core
PIC
Data Bus Width
8 bit
Data Ram Size
1.5 KB
Interface Type
CCP/ECCP/EUSART/I2C/MSSP/SPI
Maximum Clock Frequency
64 MHz
Number Of Programmable I/os
36
Number Of Timers
4
Maximum Operating Temperature
+ 85 C
Mounting Style
SMD/SMT
3rd Party Development Tools
52715-96, 52716-328, 52717-734, 52712-325, EWPIC18
Development Tools By Supplier
PG164130, DV164035, DV244005, DV164005, PG164120, DV164136
Minimum Operating Temperature
- 40 C
On-chip Adc
14-ch x 10-bit
Package
44QFN EP
Device Core
PIC
Family Name
PIC18
Maximum Speed
64 MHz
Operating Supply Voltage
2.5|3.3 V
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With
DM240313 - BOARD DEMO 8BIT XLPAC164112 - VOLTAGE LIMITER MPLAB ICD2 VPPDM164124 - KIT STARTER FOR PIC18F4XK20AC164322 - MODULE SOCKET MPLAB PM3 28/44QFN
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2009 Microchip Technology Inc.
3.11.1
Unlike writing Data EEPROM Memory, writing Flash program memory requires that the
locations being written are erased first. When erased, a program memory location has
all bits set to ‘1’. Thus an erased byte has the hex value 0xFF. Writing a program
memory location sets the appropriate bits to ‘0’, but a write cannot set a bit ‘1’. Also
different from EEPROM operations is that program memory erases and writes cannot
operate on a single byte, but instead operation on “blocks” of a particular number of
bytes.
The PIC18F45K20 erase block size is 64 bytes. This means it will always erase 64
sequential bytes at once, and the block must start at an address that is a multiple of 64.
For example, we could erase the 64 bytes from address 128 through 191 at once, but
not the 64 bytes from address 100 through 163.
To erase a 64 byte block of program memory, we use a rom pointer to set the address
of the block to be erased, and use EECON1 to control the erase. Setting the pointer
address puts the address in the TBLPTRx Special Function Registers. These 3
registers hold the address for program memory operations with TBLRD and TBLWR
assembly instructions. The MPLAB C Compiler handles these tasks for us. The
EEPGD bit, EECON1, is set to ‘1’, so the operation affects program memory and not
data EEPROM. The CFGS bit is set to ‘0’, as we do not want to select the Configuration
bits. To select an erase operation as opposed to a write operation, bit FREE of
EECON1 is set to ‘1’. WREN is then set to ‘1’ to enable write/erase operations.
Next, the EECON2 sequence must be followed as with data EEPROM writes, and the
WR bit of EECON1 is set to initiate the write.
As with a data EEPROM write, an erase or write to Flash program memory takes up to
several ms to complete. While there is an active erase or a write operation to program
memory, all microcontroller program execution is halted since it is possible the
microcontroller might attempt to execute instructions from the locations being erased
or written. This would be illegal, as the program memory location’s value is in an
indeterminate state until the operation has completed.
The PIC18F45K20 write block size is 32 bytes. This requires that we write 32
sequential bytes at a time. As with erasing, the first byte must be at an address that is
a multiple of the block size, 32.
The sequence for writing program memory is very similar to that for erasing. The
differences are that a ROM pointer is used to write the 32 locations, and that the
EECON1 bit, FREE, is cleared to select a write operation. Don’t forget that the locations
to be written must be erased first!
// point to address 2176, which is a multiple of 64
rom_pointer = (near rom char *)0x880;
EECON1bits.EEPGD
EECON1bits.CFGS
EECON1bits.FREE
EECON1bits.WREN
INTCONbits.GIE
EECON2
EECON2
EECON1bits.WR
INTCONbits.GIE
Erasing and Writing Flash Program Memory
=
=
0x55;
0xAA;
PICkit™ 3 Debug Express Lessons
=
=
=
=
= 1;
= 1;
=
1;
0;
1;
0;
1;
//
//
//
//
//
//
//
//
point to flash program memory
not configuration registers
we're erasing
enable write/erase operations
Disable interrupts
Begin Write sequence
Set WR
re-enable interrupts
bit to begin EEPROM write
DS41370C-page 63

Related parts for PIC18F45K20-I/ML