|
|
View previous topic :: View next topic |
Author |
Message |
nurquhar
Joined: 05 Aug 2006 Posts: 149 Location: Redditch, UK
|
setting up clock from 18F67J10 |
Posted: Wed Feb 06, 2008 12:25 pm |
|
|
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
|
|
Posted: Wed Feb 06, 2008 5:09 pm |
|
|
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
|
|
Posted: Thu Feb 07, 2008 1:46 am |
|
|
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') ;
}
}
|
|
|
|
|
|
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
|