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

setting up clock from 18F67J10

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



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

setting up clock from 18F67J10
PostPosted: Wed Feb 06, 2008 12:25 pm     Reply with quote

Whats the correct way to setup the PLL x 4 clock so I get 40Mhz system ? I am using PCH 3.249 and I have the the OSC1/2 pins hooked up to a 10Mhz xtal. The following code seems to run the PIC correctly at 10Mhz as I see the correct chars on serial port. How do I enable the PLL x 4 using CCS ? I have looked the following section in the header but I am none the wiser !

Whats in the header :

Code:
////////////////////////////////////////////////////////////////// INTERNAL RC
// Constants used in setup_oscillator() are:
#define OSC_INTRC   3
#define OSC_NORMAL  2
#define OSC_TIMER1  1
#define OSC_IDLE_ON_SLEEP  0x80
// Result may be (ignore all other bits)
#define OSC_STATE_EXT_RUNNING 8


My Code :


Code:
#include <18F67J10.h>
#use delay(clock=10000000)
#fuses H4_SW,NOXINST,NOWDT,NOPROTECT,NOFCMEN,CCP2C1
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,enable=PIN_C0)



void main()
{
   while(1) {
      putc('a') ;
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 06, 2008 5:09 pm     Reply with quote

The .H file for vs. 4.066 looks like this:
Quote:
// Constants used in setup_oscillator() are:
#define OSC_PLL_ON 0x4000
#define OSC_PLL_OFF 0
#define OSC_INTRC 3
#define OSC_NORMAL 2
#define OSC_TIMER1 1
#define OSC_IDLE_ON_SLEEP 0x80
// Result may be (ignore all other bits)
#define OSC_STATE_EXT_RUNNING 8
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

PostPosted: Thu Feb 07, 2008 1:46 am     Reply with quote

Dear PCM

Your a star, thanks for the "un-documented" info. I have corrected my code as follows and program now sends the correct chars when delay is set to 40Mhz.

Code:
// Constants used in setup_oscillator() are:
#define OSC_PLL_ON 0x4000
#define OSC_PLL_OFF 0

#include <18F67J10.h>
#use delay(clock=40000000)
#fuses H4_SW,NOXINST,NOWDT,NOPROTECT,NOFCMEN,CCP2C1
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,enable=PIN_C0)


void main()
{
   setup_oscillator(OSC_PLL_ON) ;
   while(1) {
      putc('a') ;
   }
}
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