![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
nuclear__
Joined: 24 Jan 2015 Posts: 63
|
setting up oscillator |
Posted: Sun Jan 25, 2015 3:35 am |
|
|
Hi everybody
i'm experimenting with this compiler.
I'm having some troubles setting oscillator.
I use 18f2550 and want to use internal 8MHz.
I tried many configurations that i found in the forum but none works good.
for example
Code: |
#fuses NOPROTECT,intrc_io,NOWDT
#use delay(clock=8000000)
|
makes everything go slowww
Code: |
#fuses NOPROTECT,intrc_io,NOWDT
#use delay(internal=8000000)
|
does the same
the only thing that works on time is
Code: |
#fuses NOPROTECT,hs,NOWDT
#use delay(clock=1000000)
|
after mixing some readings , i tried to use #byte osccon 255, hoping that it would work but there is probably a syntax error.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Sun Jan 25, 2015 4:33 am |
|
|
What are you actually wanting to do with the chip?.
Understand that this chip _requires_ the external oscillator if USB is to be used.
What compiler version?.
In a thread here a few months ago, after another poster had problems, PCM_programmer found that the actual oscillator layout, does not quite match what the data sheet shows (fun....). There is actually a path from the internal oscillator MUX, to the CPUDIV fuses. These default to '11' (/4), so the poster was getting 1/4 the speed he expected.
Use:
Code: |
#fuses NOPROTECT,INTRC_IO,NOWDT,CPUDIV1
#use delay(clock=8MHz, internal=8MHz)
|
|
|
![](templates/subSilver/images/spacer.gif) |
nuclear__
Joined: 24 Jan 2015 Posts: 63
|
|
Posted: Sun Jan 25, 2015 5:06 am |
|
|
I'm using 5.005, i tried your code too but no luck.
I'm just playing with it, i dont want to use usb or anything complex. Only rs232 ,play with lcd and blink leds!
I try to migrate from a basic compiler i have, so i go step by step.
Thats really wired . I cannt find anything more than what i try, in documentations spread around.
I think whatever i declare device works at 1 mhz .
How can i set osccon value manualy?
Thank you |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Sun Jan 25, 2015 8:27 am |
|
|
Seriously, 5.005, is a _beta_ version. The first working V5 compilers were at least a couple of versions later. The earliest I have kept as 'possibly working' is 5.010, so I can't do a comparison compile to find what is likely to be wrong.... |
|
![](templates/subSilver/images/spacer.gif) |
guy
Joined: 21 Oct 2005 Posts: 291
|
|
Posted: Sun Jan 25, 2015 2:36 pm |
|
|
For internal oscillator maybe try setup_oscillator(OSC_8MHZ) inside your code for example?
I remember struggling with a PIC18F4550 to make it work with USB at the right speed with a 12MHz crystal. Eventually what worked was:
Code: |
#fuses HSPLL,PLL3,CPUDIV3,NOFCMEN,NOIESO,PUT,BROWNOUT_SW,VREGEN
#fuses NOWDT,WDT32768,CCP2C1,NOPBADEN,NOLPT1OSC,STVREN,NOLVP,NOXINST
#use delay(clock=24000000) // 12Mhz xtal
|
Hope this helps... |
|
![](templates/subSilver/images/spacer.gif) |
nuclear__
Joined: 24 Jan 2015 Posts: 63
|
|
Posted: Mon Jan 26, 2015 4:27 am |
|
|
Hi
It's not version problem.. A collegue that has 5.03x tested it and it did the same.
Thanks guy i will try that. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Mon Jan 26, 2015 5:05 am |
|
|
Guy's code is for an external crystal at 12MHz. Won't work without the crystal.
You are using the explicit setup I posted. This has worked for me in the past.
However as Guy says, add this:
Code: |
#include <18F2550.h>
#fuses NOPROTECT,INTRC_IO,NOWDT,CPUDIV1,NOPBADEN
#use delay(clock=8MHz, internal=8MHz)
void main(void)
{
//variable declarations
setup_oscillator(OSC_8MHZ|OSC_INTRC);
//rest of code
while(TRUE)
{
output_toggle(PIN_B0);
delay_ms(100);
}
}
|
On the 5.03x, I've seen quite a lot of problems starting to appear with the latest compilers. Currently using 5.028, as the most reliable recent release. I'd be happier if you said you had tried it on something around this area, than a .03x version....
Have just tried this on a chip, and it merrily gives 5Hz as expected. |
|
![](templates/subSilver/images/spacer.gif) |
nuclear__
Joined: 24 Jan 2015 Posts: 63
|
|
Posted: Mon Jan 26, 2015 3:16 pm |
|
|
Ttelmah wrote: | Guy's code is for an external crystal at 12MHz. Won't work without the crystal.
You are using the explicit setup I posted. This has worked for me in the past.
However as Guy says, add this:
Code: |
#include <18F2550.h>
#fuses NOPROTECT,INTRC_IO,NOWDT,CPUDIV1,NOPBADEN
#use delay(clock=8MHz, internal=8MHz)
void main(void)
{
//variable declarations
setup_oscillator(OSC_8MHZ|OSC_INTRC);
//rest of code
while(TRUE)
{
output_toggle(PIN_B0);
delay_ms(100);
}
}
|
On the 5.03x, I've seen quite a lot of problems starting to appear with the latest compilers. Currently using 5.028, as the most reliable recent release. I'd be happier if you said you had tried it on something around this area, than a .03x version....
Have just tried this on a chip, and it merrily gives 5Hz as expected. |
Well that was enough by itself
#fuses NOPROTECT,INTRC_IO,NOWDT,CPUDIV1,NOPBADEN
#use delay(clock=8MHz, internal=8MHz)
Probably CPUDIV1 is the key.
I will go on with some experiments and reading.
Thank you all, especialy Ttelmah ! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Tue Jan 27, 2015 8:42 am |
|
|
Which is what I said right at the start, and you said didn't work. |
|
![](templates/subSilver/images/spacer.gif) |
nuclear__
Joined: 24 Jan 2015 Posts: 63
|
|
Posted: Tue Jan 27, 2015 8:49 am |
|
|
Ttelmah wrote: | Which is what I said right at the start, and you said didn't work. |
I miss this word. ![Confused](images/smiles/icon_confused.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Tue Jan 27, 2015 9:44 am |
|
|
I think the phrase aaargh! applies!.... ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|