Using PIC18F2450 with Microchip AN956 CDC
Firmware
Microchip PIC18F2450/4450 is the stripped-down version of
PIC18F2454/2550/4455/4550 USB microcontrollers. The major reason was the
cost reduction and some functionality is missing, notably EEPROM,
Comparator, SPI and Parallel Port (for 4455/4550 devices). The size of
SRAM was reduced to 768 bytes, which left only 256 bytes for USB dual
access RAM. Here are the notes how to make the AN956 code sample working
with PIC18F2450. The major difference is the size of USB RAM. USB RAM is
special dual port memory moving data between PIC core and USB Serial
Interface Engine. For PIC18FXX5X devices that memory is 1 Kbyte and it
is allocated in Bank 4 thru Bank 7 (400h - 7FFh). Bank 4 is dedicated
for endpoint buffer control, while Banks 5 – 7 are available for USB
data, see picture below:

PIC18F2450 device have only Bank 4 available for
USB, when part of it used for endpoint buffer control and the remaining
part available for USB data:

The Microchip CDC Firmware is using only 3
endpoints and USB data buffer of 128 bytes and defined in usbmmap.c, see
code snippet below.
/******************************************************************************
* Section C: CDC Buffer
******************************************************************************
*
*****************************************************************************/
#pragma udata usbram5a=0x500
//See Linker
Script,usb5:0x500-...
#if defined(USB_USE_CDC)
volatile far unsigned
char cdc_notice[CDC_INT_EP_SIZE];
volatile far unsigned
char cdc_data_rx[CDC_BULK_OUT_EP_SIZE];
volatile far unsigned
char cdc_data_tx[CDC_BULK_IN_EP_SIZE];
#endif
#pragma udata
All you have to do – just comment out line with “#pragma
udata usbram5a”, as PIC18F2450 is sharing the same usbram4 data
section for buffer descriptors and USB data:
/******************************************************************************
* Section C: CDC Buffer
******************************************************************************
*
*****************************************************************************/
//#pragma udata usbram5a=0x500 //See Linker
Script,usb5:0x500-...
#if defined(USB_USE_CDC)
volatile far unsigned
char cdc_notice[CDC_INT_EP_SIZE];
volatile far unsigned
char cdc_data_rx[CDC_BULK_OUT_EP_SIZE];
volatile far unsigned
char cdc_data_tx[CDC_BULK_IN_EP_SIZE];
#endif
#pragma udata
And don't forget to use
PIC18F2450.lkr file...
|