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

18f4455 Clock and connection review???

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



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

18f4455 Clock and connection review???
PostPosted: Thu Feb 28, 2008 8:52 am     Reply with quote

Hi everybody,
I have a problem with a 18F4455.

I'm working in debugging, my program doesn't contain anything, just the fuses declaration:
Code:
#include <18F4455.h>
#device ICD=TRUE
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOLPT1OSC                //Timer1 configured for higher power operation
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL12                    //Divide By 12(48MHz oscillator input)
#FUSES CPUDIV4                  //System Clock by 4
#FUSES NOUSBDIV                 //USB clock source comes from primary oscillator
#FUSES NOVREGEN                 //USB voltage regulator disabled
#FUSES ICPRT                    //ICPRT enabled

#use delay(clock=20000000)


The program is loading into the target without problem, and at the windows "Clock and Connection Review" appears.
I can read: "Check the target oscillator and MCLR. Make sure the target clock match the clock fuse and that the target is oscillating..."

I have a 20 MHz quartz with two 15pF capatitors connected to the pic, and it's oscillating correctly. i have 5V on MCLR pin.

I think my fuses configuration are good...

Do you have any idea about this problem?

Thanks,
Franck.
Ttelmah
Guest







PostPosted: Thu Feb 28, 2008 9:08 am     Reply with quote

Some comments, then the answer...

Do you actually have an external _oscillator_, or just a crystal?. You are using the HS fuse, which suggests the latter.
Why on earth use such a high speed oscillator?. The whole 'point' of the oscillator design, is to reduce power, and EMI, by avoiding the need for such a fast external signal. Though the chip is specified to support this frequency of oscillator, it _only_ does so, if the supply is good.
I'd add the PUT fuse. At such a frequency, the ocillators have a habit of starting incorrectly, and then recovering latter...
Your oscillator setup, is illegal for the frequency input. Look at the data sheet. What is the maximum oscillator frequency, using HS, as opposed to HSPLL?....

Your clock frequency, will _not_ be 20MHz.
Your fuses specify that the incoming signal, is divided by 12, to give 4Mhz, then multiplied by 24 to give 96MHz. This is then divided b 2 to give 48MHz for the USB. Your CPU, is fed _directly_ from the incoming clock, fed into the CPUDIV divider. As such, it'll be 48/4MHz. 12MHz, not 20MHz...

However the big problem is your lack of code.
CCS, by default, fills the unused memory with 'sleep' instructions, which inherently stop the clock. So since you have no code, the ICD, is seeing this happening.

Best Wishes
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

PostPosted: Thu Feb 28, 2008 10:35 am     Reply with quote

Hi Ttelmah,
Thanks for your reply.

It's right, I'm using a crystal.
I choose a 20Mhz because I wasn't sure which crystal frequency I need for the USB. So I used the same than the PIC-USB-STK board from Olimex...

About the PLL fuse I thought they wouldn't be use if I'm not setting the HSPLL fuse.

The problem was not in the code, when I said that I don't have any code, I wanted to say no code in the the main loop: while(true){}.

However, I put the PUT fuse and remove the PLL prescaler like you said and it's working.

Just for info, now the fuse setting is:
Code:
#include <18F4455.h>
#device ICD=TRUE
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV1                  //No System Clock Postscaler
#FUSES NOUSBDIV                 //USB clock source comes from primary oscillator
#FUSES NOVREGEN                 //USB voltage regulator disabled
#FUSES NOICPRT                  //ICPRT disabled

#use delay(clock=20000000)


I have to check properly all the other fuse, but at least I'm in good shape.

Thanks a lot for your help.

Franck.
Ttelmah
Guest







PostPosted: Thu Feb 28, 2008 3:52 pm     Reply with quote

If you actually have a 20MHz crystal, and you want the CPU to run at 20MHz, then you need to select CPUDIV1 (as you have now), and PLL5 (to generate the useable USB clock), with the USBDIV fuse selected. This will give the 20Mhz for the CPU, and the required 96Mhz for the USB from this crystal.
A search, should find a fairly longish description I published here some time ago, about how to configure the oscillator on these chips.
Best Wishes
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

PostPosted: Fri Feb 29, 2008 11:46 am     Reply with quote

Thanks a lot.
Franck.
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