![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
sandrewww Guest
|
problems setting clock on 18F2550 |
Posted: Wed Jun 28, 2006 9:29 pm |
|
|
Hey,
hopefully someone can help me figure out what's going on with this problem..
I just started using the 18F2550 (I've been using the PCH compiler with MPLAB 7.0 and the ICD2), and I'm having problems setting the clockrate on the chip. I have an olimex development board with a 20Mhz crystal.
Attempting to run the following code fails (nothing happens):
Code: |
#include <18F2550.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
void main()
{
while(1)
{
delay_ms(100);
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
}
}
|
whereas, if I specify the 18F2520.h file, and use #INTRC -- it blinks the led...
Code: |
#include <18F2520.h>
#fuses INTRC, NOWDT, NOLVP
#use delay(clock=8000000)
void main()
{
while(1)
{
delay_ms(100);
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
}
}
|
I've tried specifying 20Mhz, as well as 8Mhz clockrates. fuse INTRC doesn't seem to be specified for 18F2550, and with fuse HS the chip just sits there.
Looking at the 18F2550.h file, LP, XT, HS, RC, EC, EC_IO and RC_IO are specified but none seem to work.
Also, the project is set up as a 18F2550 project.
Am I missing something simple?[/code] |
|
![](templates/subSilver/images/spacer.gif) |
epideath
Joined: 07 Jun 2006 Posts: 47
|
|
Posted: Wed Jun 28, 2006 11:02 pm |
|
|
You could try changing the delay setting to match the crystal you say that is used (20MHz) could be that things are just happening too fast to see.
#use delay(clock=20000000)
instead of
#use delay(clock=8000000)
Regards |
|
![](templates/subSilver/images/spacer.gif) |
sandrewww Guest
|
|
Posted: Thu Jun 29, 2006 9:08 am |
|
|
yeah, i did try setting the clockdelay to 20000000 but it didn't help. i also looked at the pins on an oscilloscope and it didn't work.
does anyone know why pieces of code on the forum/examples use #HSPLL, but when try to specify it, the compiler complains at me? |
|
![](templates/subSilver/images/spacer.gif) |
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Jun 29, 2006 9:14 am |
|
|
Did you check the LST file to see if the fuses being programmed match those of the datasheet? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 29, 2006 1:37 pm |
|
|
Post the model number of your Olimex board. Post a link to the
webpage that has the schematic for that board.
Also, you keep putting a '#' in front of fuse settings, in your posts.
There is no '#' symbol in the constants. It's just INTRC or INTRC_IO. |
|
![](templates/subSilver/images/spacer.gif) |
sandrewww Guest
|
|
Posted: Thu Jun 29, 2006 8:27 pm |
|
|
the schematic for the olimex board is at:
olimex.com/dev/images/pic-p28-sch.gif
yes I know the fuses don't have '#'s in front of them, sorry (I was thinking of the '#fuse' declaration/preproc syntax)
is it possible this is a compiler version problem? I have PCH 3.214.
I tried compiling the code you posted at ccsinfo.com/forum/viewtopic.php?p=62694 but it doesn't work -- the compiler also says that the 'NOBADEN' fuse does not exist.
Quote: | Unknown keyword in #FUSES "NOBADEN" |
Maybe you meant it more as an example though..
I haven't been able to verify if the registers are being set correctly (in the .LST file), mainly because I've never set it via the register before and I'm not familiar with the asm/addresses to do it. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 29, 2006 9:50 pm |
|
|
Does your Olimex board have the 20 MHz crystal installed ?
The photo on at the following link shows a crystal right below the
28-pin DIP socket. Is it installed on your board ?
http://olimex.com/dev/pic-p28.html
Did the board come with the crystal installed, or did you install it ?
Can you read the frequency markings on the top of the crystal ?
Is it 20 MHz ?
Also, look on the back of the board, near the pads for the crystal.
Can you see two surface-mount capacitors there ?
They should look similar to this:
http://rocky.digikey.com/WebLib/Panasonic/Web%20Photos/MLCC%20%200805%20%20T.6.jpg |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Jun 29, 2006 11:38 pm |
|
|
sandrewww wrote: |
I tried compiling the code you posted at ccsinfo.com/forum/viewtopic.php?p=62694 but it doesn't work -- the compiler also says that the 'NOBADEN' fuse does not exist.
Quote: | Unknown keyword in #FUSES "NOBADEN" |
|
The keywords are contained in the header file 18F2550.h
For this processor the keyword is NOPBADEN
Also try adding the NOBROWNOUT fuse.
This particular PIC has the embedded USB peripheral and, as a result, it has a different clock structure to the general run of the mill PIC18F. You have specified the HS mode but you also need to configure the prescaler, and select the clock source. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
![](templates/subSilver/images/spacer.gif) |
sandrewww
Joined: 29 Jun 2006 Posts: 8
|
|
Posted: Wed Jul 05, 2006 6:49 pm |
|
|
Well,
'NOPBADEN' doesn't work either.
I tried using the fuse setup from a project I found online:
http://www.semifluid.com/PIC18F2550_usb_hid_oscilloscope/18F2550%20USB%20HID%20CRC%20Oscilloscope.c
He used the CCS compiler and same PIC.
However I can't use the following fuses from his code, they aren't in my 18F2550.h file:
VREGEN,CPUDIV1,PLL5,USBDIV
fuses in my .h file:
Code: | Fuses: LP,XT,HS,RC,EC,EC_IO,H4,RC_IO,PROTECT,NOPROTECT,OSCSEN
Fuses: NOOSCSEN,NOBROWNOUT,BROWNOUT,WDT1,WDT2,WDT4,WDT8,WDT16,WDT32
Fuses: WDT64,WDT128,WDT,NOWDT,BORV20,BORV27,BORV42,BORV45,PUT,NOPUT
Fuses: CPD,NOCPD,NOSTVREN,STVREN,NODEBUG,DEBUG,NOLVP,LVP,WRT,NOWRT
Fuses: WRTD,NOWRTD,WAIT,NOWAIT,MCU,CPU,CPU_BB,EMCU,CCP2B3,CCP2C1
Fuses: WRTC,NOWRTC,WRTB,NOWRTB,EBTR,NOEBTR,EBTRB,NOEBTRB,CPB,NOCPB
Fuses: MCLR,NOMCLR,E4_IO,E4_SW_IO,H4_SW,WDT256,WDT512,WDT1024
Fuses: WDT2048,WDT4096,WDT8192,WDT16384,WDT32768,ECCPE,ECCPH,CCP2E7 |
no mention of PLL modes, or anything. it looks like i'm legitimately missing stuff. anyone know why?
PCM Programmer: yes the crystal is installed, it came that way, 20mhz on the label, capacitors are also installed -- also came that way
Thanks for the responses,
-Andrew |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 05, 2006 10:52 pm |
|
|
I took your program and compiled it with PCH vs. 3.249, programmed
it into an 18F4550 and ran it on a PicDem2-Plus board, with a 20 Mhz
crystal. It worked. The 18F4550 is the same as the 18F2550 that
you're using, except that it's in a 40-pin package instead of 28-pin.
Code: |
#include <18F4550>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
void main()
{
while(1)
{
delay_ms(100);
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
}
} |
I don't have your version of the compiler to test (PCH vs. 3.214).
Since you have such an early version, it's possible that the start-up
code isn't properly configuring Port A for digital i/o. You can test
this by adding the lines shown in bold below. Those lines will
configure all analog pins for digital i/o. See if this makes it work.
Quote: |
#include <18F4550>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#byte ADCON1 = 0xFC1
void main()
{
// Set Analog pins to all be digital i/o.
ADCON1 = 0x0F;
while(1)
{
delay_ms(100);
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
}
} |
With regard to the missing fuses, your version of the compiler is fairly old.
Vs. 3.214 came out in early December 2004. They've added a lot more
fuses since then. Here's some of them:
Code: | //////// Fuses: HSPLL,PLL1,PLL2,PLL3,PLL4,PLL5,PLL6,PLL10,PLL12,CPUDIV1
//////// Fuses: CPUDIV2,CPUDIV3,CPUDIV4,USBDIV,NOUSBDIV,VREGEN,NOVREGEN |
|
|
![](templates/subSilver/images/spacer.gif) |
jb Guest
|
|
Posted: Thu Aug 03, 2006 5:53 am |
|
|
for use of undefined fuse ( old version ) you have to edit your device in Tools -> Devices editor -> chose it ( pic18f4550 for example) -> Edit
if the fuse is not known for example HSPLL you have to define it in the upper right corner you have a table , ADD the name of the FUSE : for HSPLL write HSPLL , MASK 0F00 ,VALUE 0E00 , CW 1!
that all.
So you can define your own fuse !!
An other way is to download the trial file of ccs compier , install it in an other folder , then copie the new devices.dat into your old folder and still use your old compiler.
It works for me. |
|
![](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
|