View previous topic :: View next topic |
Author |
Message |
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
blink led with pic18f4450 |
Posted: Tue Feb 08, 2011 9:56 am |
|
|
I'm trying to make an Led blink with a pic 18f4450 what are the right fuses? I'm not using a crystal
this is my code:
Code: |
#include <18F4450.h>
#fuses NOWDT,PUT,BROWNOUT,NOLVP,CPUDIV1, NOBROWNOUT, XT
#use delay(clock=4000000)
//======================================
void main(void)
{
while(1)
{
output_high(PIN_D3); // Blink an LED on Pin D3
delay_ms(200);
output_low(PIN_D3);
delay_ms(200);
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Feb 08, 2011 10:55 am |
|
|
If using MPLAB you have to change the 'project>build configuration> ' from 'debug' to 'release' and recompile BEFORE you burn your PIC ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
|
Posted: Tue Feb 08, 2011 12:10 pm |
|
|
it takes forever to turn on and off, I'm using pickit2, I think that might be a problem. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 08, 2011 12:12 pm |
|
|
What is your compiler version ? |
|
|
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
|
Posted: Tue Feb 08, 2011 12:15 pm |
|
|
is 4.104, this is my new code and the led turns on and off every second
Code: | #include <18F4550.h>
#FUSES INTRC, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT
#use delay(clock=8000000)
//============================
void main()
{
while(1)
{
output_high(PIN_D2);
delay_ms(1);
output_low(PIN_D2);
delay_ms(1);
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Feb 08, 2011 12:24 pm |
|
|
Are you sure that you're NOT in 'debug' mode ???
MPLAB defaults to it, don't know how a PICKIT programs the PIC.
How do you go from the compiler to the PIC , codewise ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Feb 08, 2011 12:26 pm |
|
|
hmmm.. wonder if the 'fuses' default is 'debug' ????
allowing icd mode ??? |
|
|
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
|
Posted: Tue Feb 08, 2011 12:27 pm |
|
|
there is no option for debug mode or releases mode like in ICD3 with the pickit2, I try both ways one way compile and program from MPLAB v8.56
and i tried with the pickit 2 programmer v2.61 both ways same results. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Feb 08, 2011 12:42 pm |
|
|
In MPLAB...did you pulldown 'projects>build configuration>' and change from 'debug' to 'release' AND recompile( build) ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 08, 2011 12:49 pm |
|
|
Add this fuse:
CCS goofs around with the default fuses between compiler versions.
In your version, you need that fuse to get the PIC to run at the correct speed. |
|
|
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
|
Posted: Tue Feb 08, 2011 2:41 pm |
|
|
Hi thank you!, it did help now it works a bit faster, it blinks 2 seconds on and 2 seconds off, anything else I can adjust to make it at the correct speed?
and I had tried to run on debugger same problem.
Quote: | #include <18F4550.h>
#FUSES INTRC, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT, CPUDIV1
#use delay(clock=8000000)
//============================
void main()
{
while(1)
{
output_high(PIN_D2);
delay_ms(10);
output_low(PIN_D2);
delay_ms(10);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 08, 2011 2:54 pm |
|
|
I installed vs. 4.104. I copied and pasted your program into an MPLAB
project. I compiled and ran the program and looked at pin D2 with
my oscilloscope. It goes 10ms high, and 10 ms low, continuously.
I suspect you're not using a real board. You're probably using a simulator. |
|
|
IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
|
Posted: Tue Feb 08, 2011 3:06 pm |
|
|
PCM programmer wrote: | I installed vs. 4.104. I copied and pasted your program into an MPLAB
project. I compiled and ran the program and looked at pin D2 with
my oscilloscope. It goes 10ms high, and 10 ms low, continuously.
I suspect you're not using a real board. You're probably using a simulator. |
I dont have a board I'm using a chip with a pickit 2, I will switch programmers, and let you know the results, I think is the programmer, because I had the same problem with pic32. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 08, 2011 3:09 pm |
|
|
I am using a PicKit 2, with MPLAB vs. 8.56. |
|
|
|