View previous topic :: View next topic |
Author |
Message |
pardal
Joined: 02 Jun 2009 Posts: 5
|
PIC18F2550 at 48MHz |
Posted: Tue Jun 02, 2009 6:38 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Jun 02, 2009 8:23 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Jun 02, 2009 8:57 am |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
pardal
Joined: 02 Jun 2009 Posts: 5
|
|
Posted: Tue Jun 02, 2009 8:59 am |
|
|
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](images/smiles/icon_lol.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 02, 2009 11:58 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
pardal
Joined: 02 Jun 2009 Posts: 5
|
|
Posted: Tue Jun 02, 2009 1:21 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 02, 2009 1:47 pm |
|
|
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". |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Jun 02, 2009 3:09 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
pardal
Joined: 02 Jun 2009 Posts: 5
|
|
Posted: Wed Jun 03, 2009 7:08 am |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
pardal
Joined: 02 Jun 2009 Posts: 5
|
|
Posted: Wed Jun 03, 2009 7:14 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 03, 2009 9:01 am |
|
|
Quote: | I'm testing the firmware with Proteus 7.5 . |
I'm testing with real hardware. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Thu Jun 04, 2009 8:04 am |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 04, 2009 11:46 am |
|
|
Have you tested my exact program for LED blinking that I posted ?
Tested it in hardware, with no other external circuits (USB, etc). |
|
![](templates/subSilver/images/spacer.gif) |
|