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 support@ccsinfo.com

turn on led

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



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

turn on led
PostPosted: Sun Sep 12, 2010 6:33 pm     Reply with quote

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);
         }
     }
}
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sun Sep 12, 2010 8:40 pm     Reply with quote

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.
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

led and button
PostPosted: Mon Sep 13, 2010 11:41 am     Reply with quote

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
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Mon Sep 13, 2010 11:43 am     Reply with quote

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!!!
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

led and button
PostPosted: Mon Sep 13, 2010 4:05 pm     Reply with quote

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
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Tue Sep 14, 2010 5:57 am     Reply with quote

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!!!
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

led+button
PostPosted: Tue Sep 14, 2010 7:10 am     Reply with quote

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
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Tue Sep 14, 2010 7:12 am     Reply with quote

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!!!
asmallri



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

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

PostPosted: Tue Sep 14, 2010 7:16 am     Reply with quote

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!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19222

View user's profile Send private message

PostPosted: Tue Sep 14, 2010 7:30 am     Reply with quote

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
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

turn on led
PostPosted: Tue Sep 14, 2010 8:15 pm     Reply with quote

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
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