View previous topic :: View next topic |
Author |
Message |
beginer Guest
|
Beginer needs help for PIC18F4550 ! |
Posted: Thu Sep 13, 2007 2:32 am |
|
|
Hi all,
I am a beginer, and now trying run a simple program for PIC18F4550.
I use the PICSTART PLUS Programmer and try to run the "LED Blink" program, but i tried so many times and it does not work.
Here is my code:
#include<18F4550.h>
//#fuses NOWDT,PUT,HS,NOPROTECT
#use delay(clock=8000000)
void main(void)
{
while(TRUE)
{
output_high(PIN_A2);
output_high(PIN_B2);
output_high(PIN_C2);
delay_ms(100);
output_low(PIN_A2);
output_low(PIN_B2);
output_low(PIN_C2);
delay_ms(100);
}
}
3 LEDs are connected to PinA2, B2, C2. And for the PIC Schematic, i just connected the MCLR to the 5V through a Resistor 1K, Vdd to 5V, Vss to Gnd, That's all.
Anybody can help me to show the error and show me how to make it work?
I have searched the same program but i am so confused and can not recognize the differrence.
Thanks! |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Thu Sep 13, 2007 6:46 am |
|
|
HS means an external oscillator. You need to connect an 8mhz crystal or resonator. Try changing the HS to the internal (i think the fuse is INTRC but look it up) and using the setup_oscillator(8mhz); command in the beginning.
edit: i'm just guessing the commands based on the pics i've worked with (452/4520 mostly) |
|
|
jfk1965
Joined: 21 Oct 2003 Posts: 58
|
|
Posted: Thu Sep 13, 2007 8:58 am |
|
|
do you have current limiting resitors in series with your LED's?
Also try a 100nF capacitor from MCLR to ground.
JFK |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Sep 13, 2007 9:04 am |
|
|
Try these fuses:
#fuses INTRC_IO,NOWDT,PUT,STVREN,NOLVP,NOPBADEN,NOFCMEN,MCLR |
|
|
beginer Guest
|
Thank you, Guys! |
Posted: Thu Sep 13, 2007 11:10 pm |
|
|
Thank all you guys, i used the 8mhz external Crystal Oscillator and now it works.
But i still wondered why when i used #fuses INTRC_IO or whatever related to internal osc, it said that: error with unknown keyword #Fuses "INTRC".
Anyway now i can continue doing my work.
Thanks once again for all your help! |
|
|
|