View previous topic :: View next topic |
Author |
Message |
noisepic
Joined: 24 Jul 2005 Posts: 20
|
What's wrong with this simple code? |
Posted: Wed Oct 26, 2005 10:35 pm |
|
|
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
|
|
Posted: Wed Oct 26, 2005 11:00 pm |
|
|
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
|
It should still work! |
Posted: Thu Oct 27, 2005 12:02 am |
|
|
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
|
|
|
neil
Joined: 08 Sep 2003 Posts: 128
|
|
Posted: Thu Oct 27, 2005 6:29 am |
|
|
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
|
|
Posted: Thu Oct 27, 2005 9:41 am |
|
|
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
|
|
Posted: Sat Oct 29, 2005 9:58 pm |
|
|
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
|
|
Posted: Sat Oct 29, 2005 11:46 pm |
|
|
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? |
Posted: Mon Oct 31, 2005 11:04 pm |
|
|
you must have right capacitors across the crystal to the ground.
you must check your mclr too!
check if your ic is working! |
|
|
Guest
|
|
Posted: Tue Oct 13, 2009 8:39 pm |
|
|
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 |
|
|
Guest
|
|
Posted: Tue Oct 13, 2009 8:54 pm |
|
|
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. |
|
|
|