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

It works but I don't know how!

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



Joined: 03 Mar 2009
Posts: 5

View user's profile Send private message

It works but I don't know how!
PostPosted: Tue Jul 21, 2009 4:08 pm     Reply with quote

I have been using the 18F2550 connected to the USB port, configured has a low speed device. These are the fuses:

Code:

#define __USB_PIC_PERIF__ 1
#include <18F2550.h>
#FUSES NOWDT                   
#FUSES WDT128                 
#FUSES HSPLL                       
#FUSES NOPROTECT               
#FUSES NOBROWNOUT             
#FUSES BORV20                   
#FUSES PUT                     
#FUSES NOCPD                   
#FUSES STVREN                 
#FUSES NODEBUG                 
#FUSES NOLVP                   
#FUSES NOWRT                   
#FUSES NOWRTD                   
#FUSES IESO                     
#FUSES FCMEN                   
#FUSES NOPBADEN               
#FUSES NOWRTC                   
#FUSES NOWRTB                 
#FUSES NOEBTR                 
#FUSES NOEBTRB               
#FUSES NOCPB                   
#FUSES NOMCLR                   
#FUSES LPT1OSC                 
#FUSES XINST                   
#FUSES PLL2                     
#FUSES CPUDIV3                 
#FUSES USBDIV                   
#FUSES VREGEN                   

#define USB_USE_FULL_SPEED  FALSE

#use delay(clock=24000000)


The external crystal works at 8 Mhz, the PLL prescaler is set to DIV2.
I would set the PLL postscaler to DIV4 to get a clock at 24Mhz for the core and 6 Mhz for the USB module, but it doesn't work.

I tried to set the PLL postscaler to DIV3, getting 32 Mhz for the core and 8Mhz for the USB module and everything works fine.

I don't understand why. The USB in LOW SPEED mode requires a clock at 6 Mhz and I don't know how it can work at 8 Mhz. Even the datasheet states the PLL postscaler should be set to DIV4.

Any thoughts?

Thanks.
ccesaretto



Joined: 03 Mar 2009
Posts: 5

View user's profile Send private message

PostPosted: Tue Jul 21, 2009 4:26 pm     Reply with quote

Ok. maybe it's just late and I should sleep.
The configuration bits are OK, and actually the PLL postscaler divides the PLL clock by 4.

CPUDIV3 just sets the configuration bits CONFIG1L[4:3] to 10, which means "divide by 3" if using the postscaler as the oscillator postscaler, but it means "divide by 4" if the postscaler is used as PLL postscaler.

Hope this make sense for you guys.

The reason I am setting the device to work at low speeds rather than full speeds is because I need to transfer few bytes every second and I was having troubles connecting the pic to some USB hubs.

I found out that the type of cable used matters and low speed devices work with any cable, even the longest.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 21, 2009 6:10 pm     Reply with quote

Quote:
#FUSES XINST

The extended instruction set is not supported by CCS. This fuse will
cause the program to behave in an erratic way. Change it to NOXINST.
Do this in all your programs.
Ttelmah
Guest







PostPosted: Wed Jul 22, 2009 2:18 am     Reply with quote

On the USB clock, for low speed, there is a /4 division, between the internal USB clock, and the USB device itself. Low speed, requires an internal USB clock at 24MHz, and full speed, 96MHz (divided by two to give 48MHz). The PLL, cannot be used with low speed operation. Section 2.3 of the data sheet. Low speed operation, is _only_ supported with a 24MHz crystal, and USBDIV set to zero. When the PLL is used, you can only select full speed operation, and the output of the PLL, _must_ be 4MHz.
Limitation of the hardware.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Jul 22, 2009 10:29 pm     Reply with quote

PCM programmer wrote:
Quote:
#FUSES XINST

The extended instruction set is not supported by CCS. This fuse will
cause the program to behave in an erratic way. Change it to NOXINST.
Do this in all your programs.


I've wondered about that. I've seen it in the datasheets, but I never use the extended instruction set -- and only just now did I look at what it does..

Is it worth it? The datasheet describes it as being good for 'C'... but is it just a hassle?

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah
Guest







PostPosted: Thu Jul 23, 2009 2:38 am     Reply with quote

It would potentially give some performance improvements, but CCS does not support it, so you would have to switch to another compiler....

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