|
|
View previous topic :: View next topic |
Author |
Message |
HobbyPIC.com Guest
|
Help with USB: 18f2550 ( RAM: 56%), 18F67J50 (RAM: 75%) |
Posted: Wed Feb 25, 2009 11:37 am |
|
|
Hi,
I think CCS has some kind of bug. I compiled this:
Code: |
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,NOBROWNOUT,USBDIV,PLL5,CPUDIV1,VREGEN,PUT
#use delay(clock=48000000)
#include "usb_cdc.h"
void main(void)
{
usb_cdc_init();
usb_init();
usb_wait_for_enumeration();
printf(usb_cdc_putc,"HELLO");
}
|
Code: |
#include <18F67J50.h>
#fuses H4_SW,NOWDT,NOXINST,STVREN,NOPROTECT,FCMEN,NODEBUG,PLL2,NOCPUDIV,MSSPMSK7,IESO
#use delay(clock=48000000)
#include "usb_cdc.h"
#bit PLLEN = 0xf9b.6 // To solve problem with PLL enable ( found on CCS forums )
void main(void)
{
PLLEN = 1;
usb_cdc_init();
usb_init();
usb_wait_for_enumeration();
printf(usb_cdc_putc,"HELLO");
}
|
It is same program to 18F2550 and 18F67J50. It is suposed that 18F2550 has 1KB RAM and 18F67J50 has 3,9KB RAM... but when I compile PCWH 4.084 tells me that 18f2550 ocuppied 56% and 18F67J50 ocuppied 75%... Anyone knows how could be this possible??
Thank you very much.
Best regards. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 25, 2009 1:07 pm |
|
|
Look in this file:
Quote: | c:\program files\picc\drivers\pic18_usb.h |
It has different USB buffer sizes, depending on the PIC that is used.
For the 18F67J50, it uses all available ram for the buffer, except for
0x500 bytes:
Quote: |
#if (getenv("DEVICE")=="PIC18F67J50") || (getenv("DEVICE")=="PIC18F66J55") || \
#define __USB_87J50__
#define USB_TOTAL_BUFFER_SPACE ((int16)getenv("RAM")-0x500) |
But for 18F2550, the program only takes 0x300 bytes for the USB buffer:
Quote: | #elif ((getenv("DEVICE")=="PIC18F2455") || (getenv("DEVICE")=="PIC18F2550") || \
(getenv("DEVICE")=="PIC18F4455") || (getenv("DEVICE")=="PIC18F4550"))
#define __USB_4550__
#define USB_TOTAL_BUFFER_SPACE ((int16)0x300) |
|
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Wed Feb 25, 2009 1:09 pm |
|
|
Yes! You're right. I have noticed that. I think this is due to the allocation of the USB total buffer space
Look at this section (pic18_usb.h)
Code: |
#if ((getenv("DEVICE")=="PIC18F87J50") || (getenv("DEVICE")=="PIC18F86J55") || \
(getenv("DEVICE")=="PIC18F86J50") || (getenv("DEVICE")=="PIC18F85J50") || \
(getenv("DEVICE")=="PIC18F67J50") || (getenv("DEVICE")=="PIC18F66J55") || \
(getenv("DEVICE")=="PIC18F66J50") || (getenv("DEVICE")=="PIC18F65J50"))
#define __USB_87J50__
#define USB_TOTAL_BUFFER_SPACE ((int16)getenv("RAM")-0x500)
#define USB_MAX_NUM_ENDPOINTS 16
#elif ((getenv("DEVICE")=="PIC18F2450") || (getenv("DEVICE")=="PIC18F4450"))
#define __USB_4450__
#if ((USB_EP3_TX_SIZE + USB_EP3_RX_SIZE + USB_EP4_TX_SIZE + USB_EP4_RX_SIZE + \
USB_EP5_TX_SIZE + USB_EP5_RX_SIZE + USB_EP6_TX_SIZE + USB_EP6_RX_SIZE + \
USB_EP7_TX_SIZE + USB_EP7_RX_SIZE + USB_EP8_TX_SIZE + USB_EP8_RX_SIZE + \
USB_EP9_TX_SIZE + USB_EP9_RX_SIZE + USB_EP10_TX_SIZE + USB_EP10_RX_SIZE + \
USB_EP11_TX_SIZE + USB_EP11_RX_SIZE + USB_EP12_TX_SIZE +USB_EP12_RX_SIZE + \
USB_EP13_TX_SIZE + USB_EP13_RX_SIZE + USB_EP14_TX_SIZE + USB_EP14_RX_SIZE + \
USB_EP15_TX_SIZE + USB_EP15_RX_SIZE) > 0)
#error This driver only supports endpoints 0, 1 and 2 for this chip.
#endif
#define USB_MAX_NUM_ENDPOINTS 3
#define USB_TOTAL_BUFFER_SPACE (0x100 - USB_MAX_NUM_ENDPOINTS*8)
#elif ((getenv("DEVICE")=="PIC18F2455") || (getenv("DEVICE")=="PIC18F2550") || \
(getenv("DEVICE")=="PIC18F4455") || (getenv("DEVICE")=="PIC18F4550"))
#define __USB_4550__
#define USB_TOTAL_BUFFER_SPACE ((int16)0x300)
#define USB_MAX_NUM_ENDPOINTS 16
#else
#error Unknown PIC device, USB not supported in this library.
#endif
#ifndef USB_USE_FULL_SPEED
#define USB_USE_FULL_SPEED TRUE
#endif
#ifndef USB_CON_SENSE_PIN
#define USB_CON_SENSE_PIN 0
#endif
#if defined(__USB_4450__)
//due to limited ram, force max packet length to 8 for this chip
#define USB_MAX_EP0_PACKET_LENGTH 8
#else
#if USB_USE_FULL_SPEED==FALSE
//slow speed requires 8byte max packet size for endpoint 0
#DEFINE USB_MAX_EP0_PACKET_LENGTH 8
#else
//for full speed you can still use 8bytes, but 64 will be faster
#DEFINE USB_MAX_EP0_PACKET_LENGTH 64
#endif
#endif
#INCLUDE <usb.h>
#define USB_BUFFER_NEEDED (USB_EP0_TX_SIZE+USB_EP0_RX_SIZE+USB_EP1_TX_SIZE+
USB_EP1_RX_SIZE+USB_EP2_TX_SIZE+USB_EP2_RX_SIZE+
USB_EP3_TX_SIZE+USB_EP3_RX_SIZE+USB_EP4_TX_SIZE+
USB_EP4_RX_SIZE+USB_EP5_TX_SIZE+USB_EP5_RX_SIZE+
USB_EP6_TX_SIZE+USB_EP6_RX_SIZE+USB_EP7_TX_SIZE+
USB_EP7_RX_SIZE+USB_EP8_TX_SIZE+USB_EP8_RX_SIZE+
USB_EP9_TX_SIZE+USB_EP9_RX_SIZE+USB_EP10_TX_SIZE+
USB_EP10_RX_SIZE+USB_EP11_TX_SIZE+USB_EP11_RX_SIZE+
USB_EP12_TX_SIZE+USB_EP12_RX_SIZE+USB_EP13_TX_SIZE+
USB_EP13_RX_SIZE+USB_EP14_TX_SIZE+USB_EP14_RX_SIZE+
USB_EP15_TX_SIZE+USB_EP15_RX_SIZE)
#if (USB_BUFFER_NEEDED > USB_TOTAL_BUFFER_SPACE)
#error You are trying to allocate more memory for endpoints than the PIC can handle
#endif
|
Quote: |
Code: |
USB_TOTAL_BUFFER_SPACE ((int16)getenv("RAM")-0x500)
|
|
|
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Wed Feb 25, 2009 1:10 pm |
|
|
Ooops..
Sorry PCM programmer. I think we have posted at the same time |
|
|
HobbyPIC.com Guest
|
|
Posted: Wed Feb 25, 2009 1:20 pm |
|
|
Thanks for your quickest and totally right answer. So If I had to use a Device library or program that uses 30% of RAM... 75 + 30 = 105% ... Do I´m out of RAM?? And all because that huge memory reservation??
Best Regards |
|
|
HobbyPIC.com Guest
|
|
Posted: Thu Feb 26, 2009 8:17 am |
|
|
Please I know that could be an easy question but really I´m out on that. I really dont know if I could reserve more 'free' RAM for my stuff modifing that value. Could you please help me?
Thanks and best regards. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 26, 2009 1:40 pm |
|
|
I believe Darren Rook of CCS wrote the USB drivers.
Email him and ask him about the necessity of the buffer size for that PIC.
Look on the "Contact" page on the main CCS website for his email address. |
|
|
HobbyPIC.com Guest
|
|
Posted: Thu Feb 26, 2009 4:35 pm |
|
|
Thanks PCM. I´ve seen on Microchip USB forums that you can disable 'EP´s' in order to free some memory. I´ll probably do that because I really dont need all that memory allocation for USB.
Best regards |
|
|
|
|
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
|