View previous topic :: View next topic |
Author |
Message |
prwatCCS
Joined: 10 Dec 2003 Posts: 70 Location: West Sussex, UK
|
PIC18F25K22 |
Posted: Wed Oct 06, 2010 5:16 pm |
|
|
Has anyone experience of using the CCS compiler (I have 4.112) with the PIC 18F25K22 ?
I have a simple led flash program running user timer0 to generate a 10mS RTC, but cannot get my head around the correct fuses to select the internal clock at 16MHZ and use of PLL to get actual clock frequency of 64Mhz. I have called setup_oscillator(OSC_64 | OSC_INTRC), but the result looks as if I am only running at 16MHZ not 64Mhz.
My next step is to toggle a port pin within the Timer0 isr and see what frequency my irqs actually occur at. _________________ Peter Willis
Development Director
Howard Eaton Lighting Ltd UK |
|
|
joergn
Joined: 15 Jul 2010 Posts: 15 Location: Hamburg Germany
|
|
Posted: Thu Oct 07, 2010 2:31 am |
|
|
Hi,
I had the same problem in the beginning.
Inside the main.h file I am just using the delay command and get
the 64Mhz PLL. Inside my main code I do not
changing the clock. Best way to check the 64Mhz speed is to use a scope and measure the fastest port pin change you can achieve directly and not
by a timer setting to exclude wrong timer settings......
Code: |
"main.h":
#include <18F45K22.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO
#FUSES NOPROTECT
#FUSES NOEBTRB
#FUSES NOEBTR
#FUSES NODELAYINTOSC
#FUSES NOWRTC
#FUSES NOLPT1OSC
#FUSES NODEBUG
#use delay(clock=64Mhz )
#use rs232(baud=19200,xmit=PIN_C6 ,rcv=PIN_C7 , parity=N,bits=8, ERRORS)
|
Regards
Joerg |
|
|
prwatCCS
Joined: 10 Dec 2003 Posts: 70 Location: West Sussex, UK
|
18F25K22 |
Posted: Thu Oct 07, 2010 5:25 am |
|
|
Hi Joerg
I have found the problem.
If you use setup_oscillator(OSC_64MHZ | OSC_INTRC) the compiler initialises OSCCON to 0x72
This does not allow the PLL to be seen as the clock source, even though you are indeed using the internal 16Mhz clock source!
If you use setup_oscillator(OSC_64MHZ ) the compiler initialises OSCCON to 0x70, and you get the use of the PLL. In this mode it is imperative to have correctly set the fuses to define the Primary Clock source as the internal oscillator. (FOSC<3:0> = 100x) in CONFIG1H
It helps to look at Fig 2.1 in the 18F25K22 data sheet which shows the "simplified" Oscillator system block diagram.
It would also have helped if the CCS compiler had warned that the use of OSC_INTRC at the same time as OSC_64MHZ (or indeed OSC_32MHZ) would not give the desired result.
regards _________________ Peter Willis
Development Director
Howard Eaton Lighting Ltd UK |
|
|
|