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

18F24J50 OSC Setup

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



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

18F24J50 OSC Setup
PostPosted: Tue May 18, 2010 1:06 pm     Reply with quote

I'm trying to understand how to set the osc on this chip and not having any luck. Not real good at understanding some of the datasheets.
My serial baud rate is off and USB is unknown device, so I'm sure I'm not setting up the speed correctly.

I'm playing with the EX_USB_SERIAL2.c file and made the following changes.

I'm running an external 20mhz osc.

The fuses I have are:
HSPLL
PLLDIV5 20mhz / 5 = 4 mhz to pll = 96mhz out pll
CPUDIV2 96mhz / 2 = 48mhz for USB and Chip

my use delay is clock=48000000.

I have garbage coming out my serial port. If I change the delay to 20000000 then serial port works but USB still doesn't.

Thanks for any insight.
Richard
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 18, 2010 2:07 pm     Reply with quote

1. Post your compiler version.

2. Post a short little (compilable) "Hello World" test program that
fails with the RS-232 output.
The program must have the #include for the PIC, #fuses statement,
#use delay(), and #use rs232(). It must have a main(), printf, and
a while(1); at the end of main().

Tell how it fails. What do you see on the terminal window ?

3. Is this being testing in Proteus or in hardware ?
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Tue May 18, 2010 2:59 pm     Reply with quote

Right now, I'm just trying to understand how to properly set the osc modes up via the data sheet. I fixed the RS232 issues by turning on the PLL in the top of my Main function using Setup_Oscillator(OSC_PLL_ON).
Funny, I never had to do that before.

I have an external 20 MHZ osc on OSC1 and OSC2. So that means I have to define PRIMARY and PLLDIV5...

#FUSES PRIMARY //Use Primary Clock Source
#FUSES HSPLL //High Speed and Use PLL

With that, I should have 4 MHZ into PLL and 96 MHZ out. The datasheet, on page 30 shows what comes out of the PLL will be divided by 2 ?? So I'm already at 48 mhz.

Now it goes to PLLEN.
Using Setup_Oscillator(OSC_PLL_ON); in my Main turns on the PLL so there is 48MHZ.

This gets my delays and serial working OK.

Now for USB.
I have 48mhz so I need to set CPDIV order to have 48 MHZ at USB Module. Is this the same as NOCPUDIV, evidently.

So with NOCPUDIV which is the same as CPUDIV1 I have it working.

So, do I understand this all correctly?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 18, 2010 3:54 pm     Reply with quote

Yes, I think so.
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