|
|
View previous topic :: View next topic |
Author |
Message |
ktallevi
Joined: 17 Dec 2005 Posts: 58
|
USB example code, high RAM usage |
Posted: Thu May 01, 2008 7:26 am |
|
|
So I took the sample ex_usb_hid program (from version 4.068), and compiled it for the PIC18F87J50.
RAM usage is at %75! This does not leave much room for the rest of my application as it requires more than %25 of the RAM. Any way to bring this USB-related RAM usage down without changing microcontrollers?
thanks |
|
|
Ttelmah Guest
|
|
Posted: Thu May 01, 2008 7:55 am |
|
|
You can reduce the RAM usage, by reducing the number of endpoints allocated. The big 'reason', is that when USB is not implemented, there is a huge lump of RAM available for 'normal use', in the area used for the USB buffers. As soon as you implement USB, a large amount of this RAM, is immediately used by the hardware, depending on the number of endpoints in use, and the size allocated for each. The default is to allocate only three endpoints on the 18F2450/4450, but 16 on the 87J chips. Look in the PIC18_usb.h file, where this is all configured. On these, all the RAM, -1280 bytes, is allocated for the USB buffer, which is where it is mainly going. You can fairly easily halve the default RAM usage on these chips, but still expect to use something like 40%...
Best Wishes |
|
|
bwhiten
Joined: 26 Nov 2003 Posts: 151 Location: Grayson, GA
|
USB Memory Allocation |
Posted: Thu May 01, 2008 7:58 am |
|
|
You can lower the USB buffer memory allocation in the pic18_usb.h
file.
Change line 166 like this:
was:
Code: | #define USB_TOTAL_BUFFER_SPACE ((int16)getenv("RAM")-0x500) |
is:
Code: | #define USB_TOTAL_BUFFER_SPACE ((int16)0x100) |
Or to some value greater than 100. I have used this modification to release RAM with the "hid" application without problems.
I also reduced the number of endpoints to 3 from 16. |
|
|
ktallevi
Joined: 17 Dec 2005 Posts: 58
|
|
Posted: Thu May 01, 2008 8:27 am |
|
|
thanks guys, RAM usage is down to %15, exactly what I needed! |
|
|
Ttelmah Guest
|
|
Posted: Thu May 01, 2008 8:31 am |
|
|
Be careful. At '15%', expect a fairly massive performance hit. This is why I mentioned 40%, which still gave full performance for me...
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|