View previous topic :: View next topic |
Author |
Message |
nina
Joined: 20 Apr 2007 Posts: 111
|
turn on led |
Posted: Sun Sep 12, 2010 6:33 pm |
|
|
Using the following code over my experimental board it is working (press button1 and led keeps on) but when I use protoboard led just stay on for a few seconds.
Note: Over protoboard I am not using external crystal and I am using a ATX (PC power supply).
Code: |
#include <16F628A.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, PUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD
#define button1 PIN_A1
#define LED7 PIN_B7
void main() {
output_low(LED7);
while(TRUE)
{
if (input(button1) == 0)
{
output_high(LED7);
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sun Sep 12, 2010 8:40 pm |
|
|
I would guess your PIC is resetting. I see you have the watchdog turned off in your code, but not all programmers obey those fuse settings. Check that the watchdog is really off. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
nina
Joined: 20 Apr 2007 Posts: 111
|
led and button |
Posted: Mon Sep 13, 2010 11:41 am |
|
|
thank you SherpaDoug
how can I make sure watch dog is off?
What can be the reasons pic being reseted?
Is there a possibility, power supply be the cause of this problem? As I am using an ATX PC power supply.
I have seen something like setup_oscillator(OSC_8MHZ | OSC_INTRC); but did not work
I tried #use delay(INTERNAL=4Mhz) it did not work
I tried #use delay(clock=2000000,PLLEN) it did not work
does anyone suggest anything, please?
Tks
Nina |
|
![](templates/subSilver/images/spacer.gif) |
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Mon Sep 13, 2010 11:43 am |
|
|
How good is your power supply (Is it clean?), also what are you doing with your MCLR pin on the protoboard? You might want to do a test where you change the MCLR pin to be an IO and see if that works. _________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
![](templates/subSilver/images/spacer.gif) |
nina
Joined: 20 Apr 2007 Posts: 111
|
led and button |
Posted: Mon Sep 13, 2010 4:05 pm |
|
|
My power supply is an ATX (used over computer). I have 5,19 v on Vcc.
Is it possible use 3 batteries (1,5 V each = 4,5 V total) to test this circuit?
thank you
Nina |
|
![](templates/subSilver/images/spacer.gif) |
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Tue Sep 14, 2010 5:57 am |
|
|
You probably could use the batteries, as long as they can handle the LED current as well. How about the MCLR pin, what is going on with that one? How is it connected in the protoboard? Did you try to disable the MCLR pin function? _________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
![](templates/subSilver/images/spacer.gif) |
nina
Joined: 20 Apr 2007 Posts: 111
|
led+button |
Posted: Tue Sep 14, 2010 7:10 am |
|
|
ECACE
MCLR pin it is not connected.
I have tried without MCLR declared at fuses but the problem remain.
What else could you suggest?
Thank you
nina |
|
![](templates/subSilver/images/spacer.gif) |
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Tue Sep 14, 2010 7:12 am |
|
|
Take a look in the datasheet for the proper connection of MCLR. If I remember off hand, you can pull it up to 5v via a 4.7K resistor.
As you stated, it works with your one board, but not with the other. This would lead me to believe you have some sort of HW difference. _________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Tue Sep 14, 2010 7:16 am |
|
|
ECACE wrote: | You probably could use the batteries, as long as they can handle the LED current as well. How about the MCLR pin, what is going on with that one? How is it connected in the protoboard? Did you try to disable the MCLR pin function? |
Put s pullup resistor on MCLR.
Do you have decoupling capacitors installed between power and ground of the PIC?
If the power supply is not connected to a PC motherboard, have you jumpered the power good signal to ensure the power supply is enabled? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Sep 14, 2010 7:30 am |
|
|
You need to also understand 'defaults'. The MCLR input is enabled, _unless_ you turn it off. Just leaving the MCLR fuse out, does not disable it.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
nina
Joined: 20 Apr 2007 Posts: 111
|
turn on led |
Posted: Tue Sep 14, 2010 8:15 pm |
|
|
Problem was related to MCLR as Ttelmah mentioned.
I just did this:
5V----10K----PIN4
The code keep the same.
Code: |
#include <16F628A.h>
#fuses INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD
#use delay(internal=4000000)
#define botao PIN_A1
#define LED PIN_B3
void main() {
output_low(LED);
while(TRUE)
{
if (input(botao) == 0)
{
output_high(LED);
}
}
}
|
Thank you very much.
Nina |
|
![](templates/subSilver/images/spacer.gif) |
|