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 CCS Technical Support

blink led with pic18f4450
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
IceMetal



Joined: 20 Nov 2008
Posts: 79
Location: white Plains, NY

View user's profile Send private message Yahoo Messenger

blink led with pic18f4450
PostPosted: Tue Feb 08, 2011 9:56 am     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 10:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 11:31 am     Reply with quote

Quote:

I'm trying to make an Led blink with a pic 18f4450 what are the right
fuses? I'm not using a crystal.

See this post for an example program that uses the internal oscillator:
http://www.ccsinfo.com/forum/viewtopic.php?t=28833&start=1
IceMetal



Joined: 20 Nov 2008
Posts: 79
Location: white Plains, NY

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Feb 08, 2011 12:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:12 pm     Reply with quote

What is your compiler version ?
IceMetal



Joined: 20 Nov 2008
Posts: 79
Location: white Plains, NY

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Feb 08, 2011 12:15 pm     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:24 pm     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:26 pm     Reply with quote

hmmm.. wonder if the 'fuses' default is 'debug' ????
allowing icd mode ???
IceMetal



Joined: 20 Nov 2008
Posts: 79
Location: white Plains, NY

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Feb 08, 2011 12:27 pm     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:42 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:49 pm     Reply with quote

Add this fuse:
Code:
 CPUDIV1

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

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Feb 08, 2011 2:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 2:54 pm     Reply with quote

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

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Feb 08, 2011 3:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 3:09 pm     Reply with quote

I am using a PicKit 2, with MPLAB vs. 8.56.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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