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

PIC18F2550 at 48MHz

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



Joined: 02 Jun 2009
Posts: 5

View user's profile Send private message

PIC18F2550 at 48MHz
PostPosted: Tue Jun 02, 2009 6:38 am     Reply with quote

Hi! I'd like do program my PIC ECU to run at 48MHz using a 8MHz crystal. The device is a USB HID class and it is working well, but the CPU is running at 8MHz. That's the configuration bits:
Code:
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                    //Crystal/Resonator with PLL enabled  ok
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES VREGEN                   //USB voltage regulator enabled
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#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 BBSIZ2K                  //2K words Boot Block size
#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 NOMCLR                   //Master Clear pin used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL2                     //Divide By 2(8MHz oscillator input)           ok
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2  ok
#FUSES CPUDIV1                  //No System Clock Postscaler 

Why does it running at 8MHz instead 48MHz?
Ttelmah
Guest







PostPosted: Tue Jun 02, 2009 8:23 am     Reply with quote

How are you actually 'proving' the device is at 8MHz?
Is this a standalone chip, or an ICD board (though you have debug disabled, some people use 'third party' tools to perform ICD)?
Do you have a 'setup_oscillator' line in your code anywhere?
What compiler version?
Show your clock setup line.

Best Wishes
Guest








PostPosted: Tue Jun 02, 2009 8:57 am     Reply with quote

Quote:
How are you actually 'proving' the device is at 8MHz?

I show time in sec in a lcd display using TIMER1. I've to configure the timer based on 8MHz clock ( crystal value ) to count correctly.

Quote:
Is this a standalone chip, or an ICD board (though you have debug disabled, some people use 'third party' tools to perform ICD)?

it's a stand alone chip, mounted in a custom board.


Quote:
Do you have a 'setup_oscillator' line in your code anywhere?
I don't.

thanks for the help!
pardal



Joined: 02 Jun 2009
Posts: 5

View user's profile Send private message

PostPosted: Tue Jun 02, 2009 8:59 am     Reply with quote

Anonymous wrote:
How are you actually 'proving' the device is at 8MHz?.

I show time in sec in a lcd display using TIMER1. I've to configure the timer based on 8MHz clock ( crystal value ) to count correctly.]

Is this a standalone chip, or an ICD board (though you have debug disabled, some people use 'third party' tools to perform ICD)?.

it's a stand alone chip, mounted in a custom board


Do you have a 'setup_oscillator' line in yout code anywhere?.
I don't.

thanks for the help!


it's my post! Laughing
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 02, 2009 11:58 am     Reply with quote

This test program blinks the LED on pin B0 at a 1 Hz rate. This means
it's running at 48 MHz. An 8 MHz crystal was used. This was tested
with vs. 4.093.
Code:
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,USBDIV,PLL2,CPUDIV1
#use delay(clock=48000000)

//==========================
void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}

If it doesn't work for you, then post your compiler version.
pardal



Joined: 02 Jun 2009
Posts: 5

View user's profile Send private message

PostPosted: Tue Jun 02, 2009 1:21 pm     Reply with quote

PCM programmer wrote:
This test program blinks the LED on pin B0 at a 1 Hz rate. This means
it's running at 48 MHz. An 8 MHz crystal was used. This was tested
with vs. 4.093.
Code:
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,USBDIV,PLL2,CPUDIV1
#use delay(clock=48000000)

//==========================
void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}

If it doesn't work for you, then post your compiler version.


It doesn't work! my CCS version is 4.068
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 02, 2009 1:47 pm     Reply with quote

Quote:
It doesn't work! my CCS version is 4.068

I installed vs. 4.068 and compiled it and downloaded it to a 18F4550
on a PicDem2-Plus board. It works. I then compiled it for the 18F2550
and compared the .LST files. They have the same code.

Explain what you mean by "It doesn't work".
Ttelmah
Guest







PostPosted: Tue Jun 02, 2009 3:09 pm     Reply with quote

If it wasn't for the USB apparently working, I'd be very suspicious there was a problem with the primary oscillator. In the original fuses, the 'fail safe' oscillator options are enabled, without PUT, which will almost certainly result in the initial startup being at 8MHz. If there was something wrong wth the primary oscillator, it'd probably drop back to 8MHz as well. If there was a fault with the primary oscillator, then PCM's test code, would not run.

Best Wishes
pardal



Joined: 02 Jun 2009
Posts: 5

View user's profile Send private message

PostPosted: Wed Jun 03, 2009 7:08 am     Reply with quote

PCM programmer wrote:
Quote:
It doesn't work! my CCS version is 4.068

I installed vs. 4.068 and compiled it and downloaded it to a 18F4550
on a PicDem2-Plus board. It works. I then compiled it for the 18F2550
and compared the .LST files. They have the same code.

Explain what you mean by "It doesn't work".


CPU clock doesn't work at 48MHz. I'm testing the firmware with Proteus 7.5 . USB connection works well, but CPU clock is still 8MHz!
pardal



Joined: 02 Jun 2009
Posts: 5

View user's profile Send private message

PostPosted: Wed Jun 03, 2009 7:14 am     Reply with quote

Ttelmah wrote:
If it wasn't for the USB apparently working, I'd be very suspicious there was a problem with the primary oscillator. In the original fuses, the 'fail safe' oscillator options are enabled, without PUT, which will almost certainly result in the initial startup being at 8MHz. If there was something wrong wth the primary oscillator, it'd probably drop back to 8MHz as well. If there was a fault with the primary oscillator, then PCM's test code, would not run.

Best Wishes


USB work well. I have had a similar problem on a MSP430 (Texas instrument ) uC. A failure in the system clock switches to other oscillator, running at 32kHz. PIC18 system clock is a new to me. If a failure happens, the clock switches?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 03, 2009 9:01 am     Reply with quote

Quote:
I'm testing the firmware with Proteus 7.5 .

I'm testing with real hardware.
Guest








PostPosted: Thu Jun 04, 2009 8:04 am     Reply with quote

PCM programmer wrote:
Quote:
I'm testing the firmware with Proteus 7.5 .

I'm testing with real hardware.


I've had already tested it in a PCB, doing leds to blink and it showed the same behavior of simulation on Proteus!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 11:46 am     Reply with quote

Have you tested my exact program for LED blinking that I posted ?
Tested it in hardware, with no other external circuits (USB, etc).
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