On PIC18, the USB controller needs its descriptors and packet buffers at a device-specific RAM address. USB_Device.inc reserves this area and sets a safe limit for ordinary variables.
Put the include first: place USB_Device.inc before your application's variable declarations. This lets the library reserve the USB area before the compiler places other variables.
TXReport and RXReport are ordinary application-side arrays. The USB controller also has its own packet buffers. A 64-byte transmit array therefore uses more than 64 bytes along the whole transmit path. Control transfers, class snapshots and other state need RAM too.
This device has 3776 bytes of physical RAM:
|
Region |
Size |
Use |
|
Below $0400 |
1024 bytes |
Ordinary variables, including stack variables and compiler work |
|
From $0400 |
2752 bytes |
The contiguous USB-accessible region |
The two sizes describe different regions; they are not reversed. The 1024-byte limit is not 1024 bytes of free space for your own variables.
USB may reserve only part of the 2752-byte region. If the reservation is 272 bytes, the unused part starts at $0510 and has 2480 bytes. Your class and buffer choices change these values, so read the current Summary rather than copying this example.
Created with the Personal Edition of HelpNDoc: Make the switch to CHM with HelpNDoc's hassle-free WinHelp HLP to CHM conversion tool