CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB example code, high RAM usage

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ktallevi



Joined: 17 Dec 2005
Posts: 58

View user's profile Send private message

USB example code, high RAM usage
PostPosted: Thu May 01, 2008 7:26 am     Reply with quote

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







PostPosted: Thu May 01, 2008 7:55 am     Reply with quote

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

View user's profile Send private message

USB Memory Allocation
PostPosted: Thu May 01, 2008 7:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 01, 2008 8:27 am     Reply with quote

thanks guys, RAM usage is down to %15, exactly what I needed!
Ttelmah
Guest







PostPosted: Thu May 01, 2008 8:31 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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