Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Архив4 / Proshin_polnostyu_ves_kursach / pic18f2455_2550_4455_4550.pdf
Скачиваний:
49
Добавлен:
07.08.2013
Размер:
7.07 Mб
Скачать

PIC18F2455/2550/4455/4550

FIGURE 6-2: TABLE WRITE OPERATION

 

 

 

 

 

 

 

 

Instruction: TBLWT*

 

 

 

 

 

 

 

 

Program Memory

 

 

 

 

 

 

 

 

Holding Registers

 

Table Pointer(1)

 

Table Latch (8-bit)

 

TBLPTRU TBLPTRH TBLPTRL

 

 

 

 

 

 

 

 

 

 

 

TABLAT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Program Memory

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(TBLPTR)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note 1: Table Pointer actually points to one of 32 holding registers, the address of which is determined by TBLPTRL<4:0>. The process for physically writing data to the program memory array is discussed in

Section 6.5 “Writing to Flash Program Memory”.

6.2Control Registers

Several control registers are used in conjunction with the TBLRD and TBLWT instructions. These include the:

EECON1 register

EECON2 register

TABLAT register

TBLPTR registers

6.2.1EECON1 AND EECON2 REGISTERS

The EECON1 register (Register 6-1) is the control register for memory accesses. The EECON2 register is not a physical register; it is used exclusively in the memory write and erase sequences. Reading EECON2 will read all ‘0’s.

The EEPGD control bit determines if the access will be a program or data EEPROM memory access. When clear, any subsequent operations will operate on the data EEPROM memory. When set, any subsequent operations will operate on the program memory.

The CFGS control bit determines if the access will be to the Configuration/Calibration registers or to program memory/data EEPROM memory. When set, subsequent operations will operate on Configuration registers regardless of EEPGD (see Section 25.0 “Special Features of the CPU”). When clear, memory selection access is determined by EEPGD.

The FREE bit, when set, will allow a program memory erase operation. When FREE is set, the erase operation is initiated on the next WR command. When FREE is clear, only writes are enabled.

The WREN bit, when set, will allow a write operation. On power-up, the WREN bit is clear. The WRERR bit is set in hardware when the WREN bit is set and cleared when the internal programming timer expires and the write operation is complete.

Note: During normal operation, the WRERR is read as ‘1’. This can indicate that a write operation was prematurely terminated by a Reset or a write operation was attempted improperly.

The WR control bit initiates write operations. The bit cannot be cleared, only set, in software; it is cleared in hardware at the completion of the write operation.

Note: The EEIF interrupt flag bit (PIR2<4>) is set when the write is complete. It must be cleared in software.

DS39632D-page 80

Preliminary

2007 Microchip Technology Inc.

PIC18F2455/2550/4455/4550

REGISTER 6-1:

 

EECON1: DATA EEPROM CONTROL REGISTER 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R/W-x

 

 

 

R/W-x

U-0

R/W-0

R/W-x

R/W-0

R/S-0

R/S-0

 

 

 

 

 

 

 

 

 

 

 

 

 

EEPGD

 

 

CFGS

 

FREE

WRERR(1)

 

WREN

WR

 

RD

bit 7

 

 

 

 

 

 

 

 

 

 

 

 

bit 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Legend:

 

 

 

 

S = Settable bit

 

 

 

 

 

 

 

R = Readable bit

 

 

W = Writable bit

 

U = Unimplemented bit, read as ‘0’

 

-n = Value at POR

 

‘1’ = Bit is set

 

‘0’ = Bit is cleared

x = Bit is unknown

 

 

 

 

 

 

 

 

 

 

bit 7

 

EEPGD: Flash Program or Data EEPROM Memory Select bit

 

 

 

 

1

= Access Flash program memory

 

 

 

 

 

 

 

0

= Access data EEPROM memory

 

 

 

 

 

 

bit 6

 

CFGS: Flash Program/Data EEPROM or Configuration Select bit

 

 

 

 

1

=

Access Configuration registers

 

 

 

 

 

 

 

0

= Access Flash program or data EEPROM memory

 

 

 

 

bit 5

 

Unimplemented: Read as ‘0

 

 

 

 

 

 

 

bit 4

 

FREE: Flash Row Erase Enable bit

 

 

 

 

 

 

 

1

= Erase the program memory row addressed by TBLPTR on the next WR command (cleared by

 

 

 

 

completion of erase operation)

 

 

 

 

 

 

 

0

=

Perform write-only

 

 

 

 

 

 

 

bit 3

 

WRERR: Flash Program/Data EEPROM Error Flag bit(1)

 

 

 

 

 

1

=

A write operation is prematurely terminated (any Reset during self-timed programming in normal

 

 

 

 

operation or an improper write attempt)

 

 

 

 

 

0

= The write operation completed

 

 

 

 

 

 

bit 2

 

WREN: Flash Program/Data EEPROM Write Enable bit

 

 

 

 

 

1

= Allows write cycles to Flash program/data EEPROM

 

 

 

 

 

0

= Inhibits write cycles to Flash program/data EEPROM

 

 

 

 

bit 1

 

WR: Write Control bit

 

 

 

 

 

 

 

 

1

=

Initiates a data EEPROM erase/write cycle or a program memory erase cycle or write cycle

 

 

 

 

(The operation is self-timed and the bit is cleared by hardware once write is complete.

 

 

 

 

 

The WR bit can only be set (not cleared) in software.)

 

 

 

 

 

0

= Write cycle to the EEPROM is complete

 

 

 

 

bit 0

 

RD: Read Control bit

 

 

 

 

 

 

 

 

1

= Initiates an EEPROM read (Read takes one cycle. RD is cleared in hardware. The RD bit can only

 

 

 

 

be set (not cleared) in software. RD bit cannot be set when EEPGD = 1 or CFGS = 1.)

 

 

0

= Does not initiate an EEPROM read

 

 

 

 

 

 

Note 1:

When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the error

 

condition.

 

 

 

 

 

 

 

 

 

2007 Microchip Technology Inc.

Preliminary

DS39632D-page 81

Соседние файлы в папке Proshin_polnostyu_ves_kursach