|
|
View previous topic :: View next topic |
Author |
Message |
hayee
Joined: 05 Sep 2007 Posts: 252
|
Problem with 18f452 and crystal |
Posted: Fri Sep 19, 2008 3:52 am |
|
|
Hi,
I am using pic18f452 and ccs compiler version (4.020).
when i use pic18f452 with 20MHz crystal it works fine but when i use it with above then 20MHz crystal i-e(22.118MHz and 27MHz) it doesn't work.
i am not getting the point where is the problem.
my initialization code is like that
Code: |
#include <18f452.h>
#fuses HS,NOLVP,NOWDT,NOBROWNOUT,PROTECT,PUT
#use delay(clock=20000000)
|
Code: |
#include <18f452.h>
#fuses HS,NOLVP,NOWDT,NOBROWNOUT,PROTECT,PUT
#use delay(clock=22118000)
|
Code: |
#include <18f452.h>
#fuses HS,NOLVP,NOWDT,NOBROWNOUT,PROTECT,PUT
#use delay(clock=27000000)
|
can anyone tell me where is an error or Is there is anyother problem. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Sep 19, 2008 5:48 am |
|
|
All version 4 compiler releases between v4.000 and v4.030 were alpha test releases. Often the most simple program failed to compile or created bad code. Don't use you v4.020 anymore.
Quote: | when i use pic18f452 with 20MHz crystal it works fine but when i use it with above then 20MHz crystal i-e(22.118MHz and 27MHz) it doesn't work. | Check the PIC18F452 datasheet, Table 22-4, Param. No. 1A (page 271): The maximum clock speed for an external crystal with the HS fuse is 25MHz, that explains the 27MHz failing. The 22MHz should be possible but these high frequencies are a bit tricky. Do you have the right capacitors added for your crystal? Note that the values given in the datasheet are general guidelines, every crystal manufacturer gives specific values for their crystals.
Are you developing on a PCB or a breadboard? Breadboards introduce lots of extra capacitance so you will have to adapt the capacitor values for this, even without capacitors the breadboard might introduce too much capacitance for stable oscillating.
To get a clock frequency above 20MHZ you could use the PLL feature of the chip, this will multiply the crystal's frequency by four. The maximum possible frequency with PLL is: a 10MHz crystal x 4 = 40MHz. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Fri Sep 19, 2008 10:25 pm |
|
|
Hi,
Thanks for the reply. I have got your point. One more question, how do I
define PLL option in CCS and does CCS version(4.020) support this function ? |
|
|
Ttelmah Guest
|
|
Posted: Sat Sep 20, 2008 4:18 am |
|
|
HS_PLL in the fuses.
This sort of thing works in the early V4 releases. I doubt if the code for it was changed at all from the late V3 stuff.
What fails in the early V4 compilers, is all the new stuff, and anything 'connected' with it. Quite basic things in functions that have new abilities in V4, just don't work, or do really 'screwy' things. Mid to late V4.03x, was where the compiler first became reasonably 'usable', with more than perhaps 98% of code working. Until about this point, 3.249, was far superior.
You should still be able to download 3.249.
Best Wishes |
|
|
|
|
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
|