Vous êtes sur la page 1sur 3

Using Table Instructions

24-bit Effective Address(EA) formation


? Configuration space is accessed by setting TBLPAG<7> (i.e. EA<23>)
?

Only means of accessing configuration space

Program Memory to Data Memory Access

2424-bit Instruction OP CODE p TBLPAG Register TBLPAG<7:0> TBLPAG<7:0> 8-bits from TBLPAG Register Source & Dest Regs 1616-bit Source/Dest. Pointer w wwwwwwwwwwwwww w
Byte Select

1515-bits from Source/Dest. Pointer

Effective 24-bit PM Address 24 2005 Microchip Technology Incorporated. All Rights Reserved.

Word Select From Op Code


Slide 83

Slide

82

2006 Microchip Technology Incorporated. All Rights Reserved.

103ASPRev G

Constant Data Access from PM Using Table Instructions


Actual 24-bit Program Memory
23 0 W Registers W0 0x0000 W1 0x1002 Phantom Byte W2 0x0003 0x00FE W3 0x1234
0 0 0 0 0 0 0 0

TBLRDH Instructions
Instruction
Tcy = 2

TBLRDH [W1], W3
TBLPAG = 0x01

Program Mem. Space Addr. 24 bits 0x0 0x00 0x0000 0x10 0x1000 0x2

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002

[0x11002]<23:16>
8bits
TBLRDH/TBLWTH

W3

0xFE

16-bits
TBLRDL/TBLWTL

W13 0x0000 0x101E W14 0x0000 W15 0x2400 0x00 0x00 0x0000 0x0000 0x12000 0x12002

TBLRDH.B/TBLWTH.B

TBLRDL.B/TBLWTL.B

TBLRDL.B/TBLWTL.B

Address = 0 to 0xFFFFFE word aligned

0x00 0x00

0x0000 0x0000

0x1FFFC 0x1FFFE

Table Instruction View of Program Memory

2006 Microchip Technology Incorporated. All Rights Reserved.

103ASPRev G

Slide

84

2006 Microchip Technology Incorporated. All Rights Reserved.

103ASPRev G

Slide

85

TBLRDH Instructions
W Registers W0 0x0000 W1 0x1003 0x1002 W2 0x0003 W3 0x12FE 0x1234 TBLPAG = 0x01

TBLRDL Instructions
W Registers W0 0x0000 W1 0x1002 W2 0x0003 0xABCD W3 0x1234 TBLPAG = 0x01

Instruction

Tcy = 2

TBLRDH.B [W1++], W3

Program Mem. Space Addr. 24 bits 0x0000 0x00 0x0000 0x10 0x1000 0x0002

Instruction

Tcy = 2

TBLRDL [W1], W3

Program Mem. Space Addr. 24 bits 0x0 0x00 0x0000 0x10 0x1000 0x2

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002

[0x11002]<23:16>
W13 0x0000 0x101E W14 0x0000 W15 0x2400

W3(low)

0xFE

[0x11002]<15:0>
W13 0x0000 0x101E W14 0x0000 W15 0x2400

W3

0xFE

0x00 0x00

0x0000 0x0000

0x12000 0x12002

0x00 0x00

0x0000 0x0000

0x12000 0x12002

Address = 0 to 0xFFFFFF
0x00 0x0000 0x1FFFC

Address = 0 to 0xFFFFFE word aligned

0x00

0x0000

0x1FFFC

W Registers W0 0x0000 W1 0x1003 0x1002 W2 0x0003 W3 0x12CD 0x1234

Instruction

Tcy = 2

TBLRDL.B [W1++], W3
TBLPAG = 0x01

Program Mem. Space Addr. 24 bits 0x0000 0x00 0x0000 0x10 0x1000 0x0002

? Program Space Visibility Enabled when CORCON<PSV> = 1 ? PSVPAG register maps 32Kb program memory segment into data memory

15
SFR Space

0x0000 0x0000

23

15
0x1234 0x1234

0 0x000000 0x001000

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002
Data Memory

PSVPAG=0 0x008000
0x5678 0x5678

[0x11002]<7:0>
W13 0x0000 0x101E W14 0x0000 W15 0x2400

W3(low)

0xFE

0x009000

0x8000

PSVPAG=1 0x010000
0xABCD

0x00 0x00

0x0000 0x0000

0x12000 0x12002
32KBytes Program Space Visibility (PSV) 0xFFFE 0x9000

0x011000

Address = 0 to 0xFFFFFF
0x00 0x00 0x0000 0x0000 0x1FFFC 0x1FFFE

PSVPAG=2 0x018000

Data Memory
2006 Microchip Technology Incorporated. All Rights Reserved. 103ASPRev G

Program Memory
103ASPRev G

Slide

88

2006 Microchip Technology Incorporated. All Rights Reserved.

Slide

89

Data Access from PM Using


Program Space Visibility
?

PSV Addressing Example


23
Data Space

0
PC<22:1> Reset Vector 0

32 KB segment of PM may be mapped into the data memory address space


? If PSV bit (CORCON<2>) is set and if SrcPointer (DM EA)<15> is then data is accessed from PM 1
2424-bit Instruction OP CODE PSVPAG Register PSVPAG<7:0> PSVPAG<7:0> 8-bits from PSVPAG Register
User Space Only

SFRs Near Data Memory Far Data Memory

Interrupt Vector Table Alternate Vector Table

User Space

Source & Dest Regs 1616-bit Source Pointer 1 wwwwwwwwwwwwwww wwwwwwwwwwwwww


Select PSV
Byte Select

On Chip User Flash Memory On Chip User Flash Memory

32KB

15
Data Space EA<15:0>

1414-bits from Source Pointer 0


Only even words can be accessed

1 0
CORCON<PSV> CORCON<PSV> = 1 PSVPAG = 0x20 ProgEA = 0x101000 DataEA = 0x9000
90
2006 Microchip Technology Incorporated. All Rights Reserved.

0 User Space only

Flash Config Words 0 PSVPAG Source reg 0


Slide 91

Effective 23-bit PM Address 23 2006 Microchip Technology Incorporated. All Rights Reserved. 103ASPRev G

Slide

103ASPRev G

Data Access from PM


Using PSV
Actual 24-bit Program Memory
23 0 W0 0x0000 W1 0x9002
0 0 0 0 0 0 0 0 8-bits 16-bits WORD access instruction

MOV Instructions (PSV)


W Registers

Instruction

Tcy = 2

MOV [W1], W3
PSVPAG = 0x02

Program Mem. Space Addr. 24 bits 0x0 0x00 0x0000 0x10 0x1000 0x2

W2 0x0003 0xABCD W3 0x1234

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002

0x00 or 0xFF

[0x11002]<15:0>
W13 0x0000 0x101E W14 0x0000 W15 0x2400

W3

0xFE

Byte access instruction with odd address

Byte access instruction with even address

0x00 0x00

0x0000 0x0000

0x12000 0x12002

Only lower 16-bits of PM location can be accessed via mapping

Address = 0 to 0x7FFFFE word aligned

0x00

0x0000

0x1FFFC

W Registers W0 0x0000 W1 0x9004 0x9003 W2 0x0003 0x12AB W3 0x1234

Instruction

Constants
Tcy = 2 Program Mem. Space Addr. 24 bits 0x0 0x00 0x0000 0x10 0x1000 0x2

Defining constants in PM for PSV, in assembly


.section .const, psv hello: .ascii Hello World! \n

MOV.B [W1++], W3
PSVPAG = 0x02

EA = 01|1002 = 0x11002
0x00 0x0000 0xABCD 0x11000 0x11002

Accessing PSV in assembly


mov mov bset.b mov mov.b #psvpage(hello),w0 w0, PSVPAG ; set PSVPAG address CORCONL,#PSV ; enable PSV operation #psvoffset(hello),w0 [w0++],w1 ;get first byte

[0x11002]<15:8>
W13 0x0000 0x101E W14 0x0000 W15 0x2400

W3

0xFE

0x00 0x00

0x0000 0x0000

0x12000 0x12002

Address = 0 to 0x7FFFFF
0x00 0x0000 0x0000 0x1FFFC 0x1FFFE

PMSPACE<23:16> cannot be accessed using PSV


2006 Microchip Technology Incorporated. All Rights Reserved. 103ASPRev G

0x00

Slide

94

2006 Microchip Technology Incorporated. All Rights Reserved.

103ASPRev G

Slide

95

Usefulness of PSV
?

PSV allows very large tables of data to be stored and accessed quickly & efficiently PSV provides a bridge to a common data/program address space (Von Neumann) but only when needed Example:
? ? Large constant data for display Sine Table

2006 Microchip Technology Incorporated. All Rights Reserved.

103ASPRev G

Slide

96

Vous aimerez peut-être aussi