MPLAB>Help>Topics>Language Tools>PIC18 Config Settings said:Code:PLL // Prescaler Selection bits: PLLDIV = 1 // No prescale (4 MHz oscillator input drives PLL directly) PLLDIV = 2 // Divide by 2 (8 MHz oscillator input) PLLDIV = 3 // Divide by 3 (12 MHz oscillator input) PLLDIV = 4 // Divide by 4 (16 MHz oscillator input) PLLDIV = 5 // Divide by 5 (20 MHz oscillator input) PLLDIV = 6 // Divide by 6 (24 MHz oscillator input) PLLDIV = 10 // Divide by 10 (40 MHz oscillator input) PLLDIV = 12 // Divide by 12 (48 MHz oscillator input) // CPU System Clock Postscaler: CPUDIV = OSC1_PLL2 // [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2] CPUDIV = OSC2_PLL3 // [OSC1/OSC2 Src: /2][96 MHz PLL Src: /3] CPUDIV = OSC3_PLL4 // [OSC1/OSC2 Src: /3][96 MHz PLL Src: /4] CPUDIV = OSC4_PLL6 // [OSC1/OSC2 Src: /4][96 MHz PLL Src: /6] // USB Clock Selection bit (used in Full Speed USB mode only; UCFG:FSEN = 1): USBDIV = 1 // USB clock source comes directly from the primary oscillator block with no postscale USBDIV = 2 // USB clock source comes from the 96 MHz PLL divided by 2 // Oscillator Selection bits: FOSC = XT_XT // XT oscillator, XT used by USB FOSC = XTPLL_XT // XT oscillator, PLL enabled, XT used by USB FOSC = ECIO_EC // External clock, port function on RA6, EC used by USB FOSC = EC_EC // External clock, CLKOUT on RA6, EC used by USB FOSC = ECPLLIO_EC // External clock, PLL enabled, port function on RA6, EC used by USB FOSC = ECPLL_EC // External clock, PLL enabled, CLKOUT on RA6, EC used by USB FOSC = INTOSCIO_EC // Internal oscillator, port function on RA6, EC used by USB FOSC = INTOSC_EC // Internal oscillator, CLKOUT on RA6, EC used by USB FOSC = INTOSC_XT // Internal oscillator, XT used by USB FOSC = INTOSC_HS // Internal oscillator, HS used by USB FOSC = HS // HS oscillator, HS used by USB FOSC = HSPLL_HS // HS oscillator, PLL enabled, HS used by USB
#include <p18f2550.h>
#include <delays.h>
#pragma config PLLDIV = 5 // need 5 for 20MHz xtal
#pragma config CPUDIV = OSC1_PLL2 // CPU Clock = 96 MHz/2 = 48 MHz
#pragma config USBDIV = 2 // 96MHz PLL/2 = 48 MHz for USB clock
#pragma config FOSC = HSPLL_HS // High Speed Crystal / Resonator with PLL enabled
#pragma config WDT = OFF // no watchdog
#pragma config LVP = OFF // LVP MUST be off
#pragma config BOR = OFF // no brown out reset
#pragma config MCLRE = ON // MCLR in use (so 10k to +5v essential)
#pragma config PWRT = ON // power up timer on
#pragma config PBADEN = OFF // disable PORTB a/d converter
#pragma config VREGEN = ON // USB Internal Voltage Regulator enabled
void main (void)
{
TRISB = 0;
PORTB = 0;
while (1)
{
PORTB = 0;
Delay10KTCYx(0);
PORTB = 0xFF;
}
}
betwixt said:Cough cough.....
With a layout like that it's a wonder anything works at all.
You MUST place capacitors across the supply lines as close to the IC as possible and you MUST ensure the ground connection to the IC is as low impedance as possible to the ground side of the crystal loading capacitors.
You oscillator could be on any frequency at the moment and there will be so much noise on the supply it is very unlikely it will be stable enough to run reliably if at all.
Brian.
anandpv2009 said:Here is the HEX file that works fine with PIC18F2550 with 20mhz (xtal)...
This code will on and off led connected to port B.
I were tested it and it works fine...
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000)
void main()
{
set_tris_b(0);
while(1)
{
output_b(0xff);
delay_ms(100);
output_b(0x00);
delay_ms(100);
}
}
Didn't changed anything...betwixt said:I doubt this is the problem but try using LATB instead of PORTB when you output the data.
Error given:anandpv2009 said:Code:#include <P18F2550.h> #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN // LINE #34 #use delay(clock=20000000) void main() { set_tris_b(0); while(1) { output_b(0xff); delay_ms(100); output_b(0x00); delay_ms(100); } }
Why you are searching this simple code.....
This is for CCS compile..
I think your next switch on will be a success
ha..am i correct
----------------------------------------------------------------------
Debug build of project `C:\Development\PIC\Projects\18F2550 Hello World\Project.mcp' started.
Language tool versions: MPASMWIN.exe v5.34, mplink.exe v4.34, mcc18.exe v3.34
Preprocessor symbol `__DEBUG' is defined.
Sat Oct 24 14:06:43 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Development\PIC\MPLAB C18\bin\mcc18.exe" -p=18F2550 /i"C:\Development\PIC\MPLAB C18\h" "main.c" -fo="C:\Documents and Settings\<profilename>\Desktop\main.o" -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
C:\Development\PIC\Projects\18F2550 Hello World\main.c:34:Error: syntax error
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Development\PIC\Projects\18F2550 Hello World\Project.mcp' failed.
Language tool versions: MPASMWIN.exe v5.34, mplink.exe v4.34, mcc18.exe v3.34
Preprocessor symbol `__DEBUG' is defined.
Sat Oct 24 14:06:43 2009
----------------------------------------------------------------------
BUILD FAILED
IDE: MPLAB 8.40 Academic Versionanandpv2009 said:You should use CCS compiler to work the above program...
Please specify your compiler name.? I think your compiler is not CCS.
You can download free version of ccs from net.
One more thing, Whats about my previously posted hex (worked or not).?
#include <p18f2550.h>
#include "delays.h"
#pragma config WDT = OFF
#pragma config MCLRE = ON
#pragma config DEBUG = OFF
#pragma config LVP = OFF
#pragma config PLLDIV = 5 // need 5 for 20MHz xtal
#pragma config CPUDIV = OSC1_PLL2 // CPU Clock = 96 MHz/2 = 48 MHz
#pragma config USBDIV = 2 // 96MHz PLL/2 = 48 MHz for USB clock
#pragma config FOSC = HSPLL_HS // High Speed Crystal / Resonator with PLL enabled
void blinkLed(unsigned char led);
void main (void)
{
ADCON0=0x00;
ADCON1=0x0f;
CMCON=7;
TRISAbits.TRISA0 = 0;
TRISAbits.TRISA1 = 0;
TRISAbits.TRISA2 = 0;
TRISAbits.TRISA3 = 0;
TRISAbits.TRISA4 = 0;
LATAbits.LATA0 = 0;
LATAbits.LATA1 = 0;
LATAbits.LATA2 = 0;
LATAbits.LATA3 = 0;
LATAbits.LATA4 = 0;
blinkLed(0);
blinkLed(1);
blinkLed(2);
blinkLed(3);
blinkLed(4);
while(1);
}
void blinkLed(unsigned char led)
{
int j; for (j=0; j<10; j++)
{
switch (led)
{
case 0:
LATAbits.LATA0 = 1;
Delay10KTCYx(0);
LATAbits.LATA0 = 0;
Delay10KTCYx(0);
break;
case 1:
LATAbits.LATA1 = 1;
Delay10KTCYx(0);
LATAbits.LATA1 = 0;
Delay10KTCYx(0);
break;
case 2:
LATAbits.LATA2 = 1;
Delay10KTCYx(0);
LATAbits.LATA2 = 0;
Delay10KTCYx(0);
break;
case 3:
LATAbits.LATA3 = 1;
Delay10KTCYx(0);
LATAbits.LATA3 = 0;
Delay10KTCYx(0);
break;
case 4:
LATAbits.LATA4 = 1;
Delay10KTCYx(0);
LATAbits.LATA4 = 0;
Delay10KTCYx(0);
break;
default:
LATAbits.LATA0 = 0;
LATAbits.LATA1 = 0;
LATAbits.LATA2 = 0;
LATAbits.LATA3 = 0;
LATAbits.LATA4 = 0;
break;
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?