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 CCS Technical Support

pic18f2455 oscillator problem

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



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

pic18f2455 oscillator problem
PostPosted: Sat May 09, 2009 4:35 am     Reply with quote

Hi all

I have a pic18f2455, a 20mhz crystal, two 15pF capacitors.

this is the program

Code:

#include "C:\pic\18f2455_led\main.h"


void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_8_BIT);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   
   while(1)
   {
      output_high(PIN_A0);
      delay_ms(1500);
      output_low(PIN_A0);
      delay_ms(1500);
   }
}

Code:

#include <18F2455.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HSPLL                    //High Speed Crystal/Resonator with PLL enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#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 PBADEN                   //PORTB pins are configured as analog input channels 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 MCLR                     //Master Clear pin enabled
#FUSES XINST                    //Extended set extension and Indexed Addressing mode enabled
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES CPUDIV1                  //System Clock /1
#FUSES VREGEN                   //USB voltage regulator enabled

#use delay(clock=20000000)


led should blink every 1500, but it doesn't. it blink very fast.
(this is a test program, the next step is adding usb full speed support, so the configuration must work also for the usb)

what is the problem?

Thanks
sorry for my english

Question
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Sat May 09, 2009 5:47 am     Reply with quote

Here is your problem.

#FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled
#FUSES PLL5 //Divide By 5(20MHz oscillator input)

Your clock is not 20MHz but much higher.... with settings like that on PIC18F4550 clock would be 48MHz Wink
adalucio



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

PostPosted: Sat May 09, 2009 6:52 am     Reply with quote

so I have to write

Code:

#use delay(clock=48000000)


is it ok?
adalucio



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

PostPosted: Sat May 09, 2009 6:58 am     Reply with quote

adalucio wrote:
so I have to write

Code:

#use delay(clock=48000000)


is it ok?


I tried it. it doesn't work, led blink very fast Bummed Out
adalucio



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

PostPosted: Sat May 09, 2009 7:06 am     Reply with quote

adalucio



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

PostPosted: Sat May 09, 2009 7:18 am     Reply with quote

OMG

now it works Question

Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                    //High Speed Crystal/Resonator with PLL enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV43                   //Brownout reset at 4.3V
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#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 PBADEN                   //PORTB pins are configured as analog input channels 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 MCLR                     //Master Clear pin enabled
#FUSES XINST                    //Extended set extension and Indexed Addressing mode enabled
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES CPUDIV1                  //System Clock by 1
#FUSES VREGEN                   //USB voltage regulator enabled

#use delay(clock=48000000)


Big thanks
Ttelmah
Guest







PostPosted: Sat May 09, 2009 7:23 am     Reply with quote

However you won't get much other code to work, till you get rid of the XINST fuse.
CCS, does _not_ use/support XINST.
A really simple program (LED flasher), won't do anything using the extended instructions, but as soon as you try to code anything more complex, the code will stop working....

Best Wishes
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