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

What's wrong with this simple code?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

What's wrong with this simple code?
PostPosted: Wed Oct 26, 2005 10:35 pm     Reply with quote

I want to make a led flash by this code. I use PIC16F88, Crystal 4 MHz
Code:

#include<16F88.h>
#fuses  NOWDT,HS,MCLR,NOLVP,NOPROTECT
#use    delay(clock=4000000)
main()
{
while(1)
     {
     output_high(PIN_B3);
     delay_ms(300);
     output_low(PIN_B3);
     delay_ms(300);
      }
}

But the led doesn't flash. What's wrong? I don't think ..by this code!
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 26, 2005 11:00 pm     Reply with quote

Change the HS fuse to XT
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kel



Joined: 17 Oct 2005
Posts: 68
Location: Brisbane

View user's profile Send private message

It should still work!
PostPosted: Thu Oct 27, 2005 12:02 am     Reply with quote

there is no problem with the code,I tried the code and it works.Check your circuit and if that is fine then change the HS fuse as indicated by Andrew!
cheers
Wink
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

PostPosted: Thu Oct 27, 2005 6:29 am     Reply with quote

Is MCLR connected to anything? are you using a pull-up. Try changing the fuse from MCLR to NOMCLR.
Bart



Joined: 12 Jul 2005
Posts: 49

View user's profile Send private message

PostPosted: Thu Oct 27, 2005 9:41 am     Reply with quote

And if your led's are to slow,change the delay to 1000. (1 sec on, 1 sec off)

How did you connect the led ? Maybe you inversed it. Did you use a not to high resistor between (need to be somewhere around 330 ohm)

Greetings.
_________________
I like Skype (www.skype.com), my username is BplotM
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

PostPosted: Sat Oct 29, 2005 9:58 pm     Reply with quote

I've checked these thing. but my PIC16F88 can't do its job.
I change another 16F88, the failure too!
I don't know why?
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Oct 29, 2005 11:46 pm     Reply with quote

It looks like a hardware problem.

Is the crystal OK?

Does it have the right value for the load capacitors?

Did you set the fuse to XT?

Are you sure you wired the LEDs the right way around?

Do you have a logic proble you could use to test the output pins?

What value series resistor did you use with the LEDS?

What is the VCC voltage?

What programmer are you using?

When you read back the code using the programmer:
are the fuses correct?
does the code match the hex file?
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
skel
Guest







Are you connecting the right capacitors?
PostPosted: Mon Oct 31, 2005 11:04 pm     Reply with quote

you must have right capacitors across the crystal to the ground.
you must check your mclr too!
check if your ic is working! Rolling Eyes
Guest








PostPosted: Tue Oct 13, 2009 8:39 pm     Reply with quote

Code:
 #include <16f88.h>
#use delay (clock=1000000)
#fuses NOLVP, NOWDT, INTRC, PUT
void main ()




**here's the header that i normal use for everything. try this out Very Happy
Guest








PostPosted: Tue Oct 13, 2009 8:54 pm     Reply with quote

Code:

#include <16f88.h>
#use delay (clock=100000)
#fuses NOLVP, NOWDT, INTRC, PUT

void main ( )
{
    setup_oscillator (osc_8mhz);
    setup_adc_ports(no_analogs) ; // all ADC pins to digital I/O
    set_tris_a(0x01);    //bit A0 is input

     while (1) //creates endless loop
     {
          { start:
               if (input(pin_A0))
                  {
                   output_bit(pin_B0,1);//LED on
                  }
               goto start; //repeat loop at "start"
          }
     }
}



This is just a little more then what i last posted....but this should definitely work for you. Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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