AN1003
DS01003A-page 12
©
2005 Microchip Technology Inc.
Memory Organization
Data banks 4 through 7 of the data memory are
mapped to special dual port RAM (see Example 2).
When the USB module is disabled, the General
Purpose Registers (GPRs) in these banks are used like
any other GPRs in the data memory space. When the
USB module is enabled, the memory in these banks is
allocated as buffer RAM for USB operation. This area
is shared between the microcontroller core and the SIE
and is used to transfer data directly between the two.
Note that the linker script has been modified to define
MSD as a single data bank of 512 bytes. The 512-byte
msd_buffer
has been defined in the MSD data bank
(see Example 1). Figure 7 shows the entire memory
map including the endpoint buffers.
EXAMPLE 1:
BUFFERS FOR MSD
(
usbmmap.c
)
FIGURE 7:
COMPLETE MEMORY
ORGANIZATION (INCLUDING
ENDPOINT BUFFERS)
EXAMPLE 2:
MODIFIED LINKER SCRIPT
#if defined(USB_USE_MSD)
volatile far USB_MSD_CBW msd_cbw;
volatile far USB_MSD_CSW msd_csw;
#pragma udata myMSD=0x600
volatile far char msd_buffer[512];
#endif
60h
5Fh
1FFh
100h
FFh
00h
Access RAM
GPR0
GPR1
2FFh
200h
3FFh
300h
400h
5FFh
7FFh
600h
GPR2
GPR3
ep0Bo
(Endpoint 0,
ep0Bi
(Endpoint 0,
ep15Bo
(Endpoint 15,
ep15Bi
(Endpoint 15,
msd_buffer
•
•
•
* The ep<n>Bo and ep<n>Bi actually declared are
dependant on the number of endpoints used in the
application.
BD Out)
BD In)
BD Out)
BD In)
[0]
[511]
•
•
•
ACCESSBANK
NAME=accessram
START=0x0
END=0x5F
DATABANK
NAME=gpr0
START=0x60
END=0xFF
DATABANK
NAME=gpr1
START=0x100
END=0x1FF
DATABANK
NAME=gpr2
START=0x200
END=0x2FF
DATABANK
NAME=gpr3
START=0x300
END=0x3FF
DATABANK
NAME=usb4
START=0x400
END=0x4FF
PROTECTED
DATABANK
NAME=usb5
START=0x500
END=0x5FF
PROTECTED
// Combine usb6 and usb7 banks to define a 512 byte msd bank .......... ..............
//DATABANK
NAME=usb6
START=0x600
END=0x6FF
PROTECTED
//DATABANK
NAME=usb7
START=0x700
END=0x7FF
PROTECTED
DATABANK
NAME=msd
START=0x600
END=0x7FF
PROTECTED
深圳市英锐恩科技有限公司
www.enroo-tech.com