|
|
View previous topic :: View next topic |
Author |
Message |
dynamitron
Joined: 18 Mar 2009 Posts: 38
|
32 MHz clock with 18f2525 : impossible !!! (solved) |
Posted: Wed Mar 18, 2009 3:08 pm |
|
|
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
|
32 MHz clock with 18f2525 : impossible !!! |
Posted: Wed Mar 18, 2009 3:16 pm |
|
|
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
|
|
Posted: Wed Mar 18, 2009 3:24 pm |
|
|
Do you have an external crystal ? If so, what is the crystal frequency ? |
|
|
dynamitron
Joined: 18 Mar 2009 Posts: 38
|
|
Posted: Wed Mar 18, 2009 3:51 pm |
|
|
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
|
|
Posted: Wed Mar 18, 2009 4:14 pm |
|
|
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
|
|
Posted: Thu Mar 19, 2009 1:05 am |
|
|
Thank you Ttelmah !!
Your last suggestion is the solution. |
|
|
Guest
|
|
Posted: Thu Mar 19, 2009 4:56 am |
|
|
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
|
|
Posted: Thu Mar 19, 2009 5:09 am |
|
|
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
|
|
Posted: Thu Mar 19, 2009 5:41 am |
|
|
Thanks:-) |
|
|
|
|
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
|