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

32 MHz clock with 18f2525 : impossible !!! (solved)

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



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

32 MHz clock with 18f2525 : impossible !!! (solved)
PostPosted: Wed Mar 18, 2009 3:08 pm     Reply with quote

hello,

Using a compiler 4.065 and a pic 18f2525, I got difficulties to run it at 32 MHz

I wrote the very simple code and looking at the pin c4 with a scope, I can not go higher than 16 MHz even if I change the value in the instruction setup_oscillator

Code:

#include <18f2525.h>
#fuses NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP,INTRC_IO,h4//NOMCLR
#use delay(clock=16000000)   
//#use delay(clock=32000000)   
//#include "stdlib.h"

#BYTE OSCCON = 0xFd3
#BYTE OSCTUN = 0xF9b


void main() {
//OSCCON = 0b01110010; // boost up to 8Mhz
//OSCTUN = 0b01000000; // mutiply by 4
setup_oscillator (osc_16MHZ);
//setup_oscillator (osc_32MHZ);


   while (TRUE) {

        delay_ms(10);
        output_High(PIN_c4);
       delay_ms(10);
      output_low(PIN_c4);
        //output_High(PIN_c4);
   }
}


I even tried to change the value directly into osccon and osctune but no success.

Any hints ?

Thanks in advance for the help


Last edited by dynamitron on Thu Mar 19, 2009 1:06 am; edited 1 time in total
andyfraser



Joined: 04 May 2004
Posts: 47
Location: UK

View user's profile Send private message

32 MHz clock with 18f2525 : impossible !!!
PostPosted: Wed Mar 18, 2009 3:16 pm     Reply with quote

Hi,

You can't say 'very simple code' without looking at the assembly language generated by the compiler. I expect you will find quite a large number of instructions being generated for your 'simple' loop.

Andy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 18, 2009 3:24 pm     Reply with quote

Do you have an external crystal ? If so, what is the crystal frequency ?
dynamitron



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

PostPosted: Wed Mar 18, 2009 3:51 pm     Reply with quote

Thanks for these first answers !!

for Andy,

the program just set and reset an output with delay between instructions and I check that I got the right delay on the scope. The delays are 10 ms to avoid a too big error due to the while instruction
Isn't it simple ? Any proposition for simplier code ?

For PCM programmer.

Indeed, I have a 4 MHz external quartz that I intend to change for a 10 MHz if I have no success with the internal oscillator.
H4/HS fuses works ok for it as I get correct delays.

What do you think ?
Ttelmah
Guest







PostPosted: Wed Mar 18, 2009 4:14 pm     Reply with quote

First, get rid of the H4 fuse. For the internal clock, the PLL, is the one controlled by software, not the fuses.

What happens first, if you try the normal CCS settings for this:
Code:

#include <18f2525.h>
#fuses NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP,INTRC_IO//,NOMCLR
#use delay(clock=32000000)   


Then what happens if you try the manual clock setting, with:
Code:

#include <18f2525.h>
#fuses NOWDT, NOPROTECT, BROWNOUT, PUT,NOLVP,INTRC_IO//,NOMCLR
#use delay(clock=32000000)   

void main(void) {
setup_oscillator (osc_8MHZ | OSC_PLL_ON);


}

In fact, you say you have an external crystal attached. I'd guess you are actually getting this *4, since the H4 fuse is overriding the internal RC setting, and hence getting 16MHz....

Best Wishes
dynamitron



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

PostPosted: Thu Mar 19, 2009 1:05 am     Reply with quote

Thank you Ttelmah !!

Your last suggestion is the solution.
Guest








PostPosted: Thu Mar 19, 2009 4:56 am     Reply with quote

Chip i use is 18xx2455.

Just wonder is it possible to use the OSC_PLL_ON for the internal (INTRC_IO ) OSC?
Code:
setup_oscillator (osc_8MHZ | OSC_PLL_ON);


What is the max cycle/fraq when using internal 8mhz?
Ttelmah
Guest







PostPosted: Thu Mar 19, 2009 5:09 am     Reply with quote

This is where 'read the data sheet' is the answer.
No.
On the 2525, there are two PLL's. One enabled by the fuses, affecting the external clock input. One enabled by the internal setting, which also affects the internal clock.
On the 2455, there is not this extra internal PLL.
The very first main page of the data sheet, for the 2455:
"Internal oscillator block:
- 8 user-selectable frequencies, from
31 kHz to 8 MHz"

While the same section for the 2525:
"Internal oscillator block:
- 8 user selectable frequencies, from 31 kHz to
8 MHz
- Provides a complete range of clock speeds
from 31 kHz to 32 MHz when used with PLL"

Note the extra line.....

Best Wishes
Guest








PostPosted: Thu Mar 19, 2009 5:41 am     Reply with quote

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