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 support@ccsinfo.com

PIC18F26J50 with internal oscillator and USB

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



Joined: 22 Jan 2010
Posts: 3

View user's profile Send private message

PIC18F26J50 with internal oscillator and USB
PostPosted: Fri Jan 22, 2010 10:37 am     Reply with quote

Hi,

I am having a problem with the PIC18F26J50, specifically with USB. I was perviously using the PIC18F14K50 with great success but have run up against a brick wall with this chip.

My hardware is pretty straight forward, I have a 1k5 running from D+ to the Vusb line and I have put a scope on both the D+ andD- and can see pulses when I plug the USB cable in, but nothing else.

Im pretty sure its something I am doing wrong with the oscillator configuration, as when I plug the USB cable in my windows host detects it but does not enumerate it, I get the hardware error message. I have an LED hooked up to an output to check if the program is actually running.
Reading other posts on the forum would indicate to me I have selected the wrong frequency or divider options.
I was hoping someone here more could take a look at my fuses and tell me where Im going wrong.

Regards

Simon


Heres my test program:
Code:
#include <18F26J50.h>
#use delay(clock=48000000)
 
#FUSES NOWDT
#FUSES NODEBUG
#FUSES NOXINST
#FUSES STVREN
#FUSES NOPROTECT
#FUSES NOFCMEN                 
#FUSES NOIESO                   
#FUSES NOCPUDIV         
#FUSES INTRC_PLL_IO   
#FUSES PLLDIV2
 
#byte OSCCON = 0xFD3
#byte UCFG  = 0xF39
#byte OSCTUNE= 0xF9B
#include <usb_cdc.h>
 
void main( void)
{
 
   OSCTUNE =  0xC0;
   OSCCON =  0xF0;
   UCFG |= 0x4;
 
   unsigned int pll_startup_counter = 600;
   while (pll_startup_counter--);
 
   output_high( PIN_B3);
   usb_init_cs();
 

    while (1)
    {
           usb_task();
 
        delay_ms(500);
        output_high( PIN_B3);
      // printf(usb_cdc_putc, "Hello World! ");
      delay_ms(500);
      input( PIN_B3);
    }
 }
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jan 22, 2010 11:01 am     Reply with quote

I'm not sure, if the clock configuration is correct, but the PIC18F26J50 doesn't specify an internal oscillator frequency
accuracy as required for USB full speed operation. The datasheet tells, it's sufficient for low speed. The typical oscillator
accuracy would however meet the USB requirement of +/- 0.25%.
Ttelmah
Guest







PostPosted: Sat Jan 23, 2010 7:11 am     Reply with quote

USB requires _total_ clock errors, not greater the 0.25% for full speed, and 1.5%, for low speed. This error, _includes_ the error from the host, which can be up to 0.05%. So the allowable maximum error for the slave devices, is 1.44% for low speed, and just over 0.24% for high speed devices.
On 'paper', the internal clock does meet the Low speed requirements.
The USB module data sheet, specifically says:

"The 8 MHz INTOSC included in all PIC18F46J50 Family
devices is extremely accurate. When the 8 MHz
INTOSC is used with the 96 MHz PLL, it may be used
to derive the USB module clock. The high accuracy of
the INTOSC will allow the application to meet
low-speed USB signal rate specifications."

The quoted accuracy (Table 29.12), is inside what is needed for low speed operation.

The 'typical' figure could potentially run high speed, over a limited temperature range, but It is unlikely to be reliable (how 'typical' is 'typical....).

So, for low speed, go ahead, but if you want high speed operation, use an external oscillator.

Best Wishes
czsimon



Joined: 22 Jan 2010
Posts: 3

View user's profile Send private message

PostPosted: Sat Jan 23, 2010 7:23 am     Reply with quote

OK, I will try the slower clock for low-speed USB. My application isnt speed sensitive so it wont be a problem if its all I can use.

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Jan 23, 2010 7:37 am     Reply with quote

To make the device enumerate as low speed, you also have to change the resistor configuration.
czsimon



Joined: 22 Jan 2010
Posts: 3

View user's profile Send private message

PostPosted: Mon Jan 25, 2010 3:40 am     Reply with quote

I managed to figure out the problem! I had a bad connection on the Vusb pin.
It now works fine in both full speed and low speed from the internal oscillator. Thanks for everyones help.
Ttelmah
Guest







PostPosted: Mon Jan 25, 2010 3:46 am     Reply with quote

Don't rely on the full speed operation though....
The 'point' is that the data sheet says the chips will 'typically' meet the timings needed for full speed, but they only _guarantee_ timings to be good enough for low speed. If you go full speed, you ar pretty certain to find devices going wrong, if the temperature gets a bit hot/cold, or with individual chip batches. If this is a commercial product, consider the problems that this is likely to cause, and whether it is worth taking the risk....

Best Wishes
gabogt3



Joined: 06 Jul 2011
Posts: 1

View user's profile Send private message

Hi, please help
PostPosted: Wed Jul 06, 2011 8:22 am     Reply with quote

czsimon wrote:
I managed to figure out the problem! I had a bad connection on the Vusb pin.
It now works fine in both full speed and low speed from the internal oscillator. Thanks for everyones help.


Hi, Please could you write what is a correct connection on the Vusb pin.
Thanks.
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