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

led is off,programming successful...help pls..

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



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

led is off,programming successful...help pls..
PostPosted: Wed Jun 11, 2014 6:59 am     Reply with quote

I tried to on/off LED for checking my hardware, but 16F877a programming is successful but my LED is off.
Code:

#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 2000000)


void main()
{

while(1)
{
output_high(PIN_D0);
delay_ms(50000);
Output_Low(PIN_D0);
Output_high(PIN_D1);


}
}

_________________
e-learner
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 7:03 am     Reply with quote

Suggestions:

MCLR not pulled up.
No current limiting resistor to the LED.
Crystal not 2MHz, or not correctly connected.

There are dozens of others, but these are probably the most obvious.
e-learner



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

RE:
PostPosted: Wed Jun 11, 2014 7:31 am     Reply with quote

link below for my connection image.
http://s28.postimg.org/45tnjodot/connection.jpg
_________________
e-learner
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 8:29 am     Reply with quote

Not easy to see anything on your image.

If LED is wrong way round you will see nothing.

If LED is correct way round most of your code is useless.
The LED will turn, on for 5s, off for a few us, repeatedly.
You will not see the turn off.

You need to check that the connections are all as intended.
Use a 'scope if possible.

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 8:48 am     Reply with quote

and (of course) it is classic 'Proteus', which means it doesn't show the power connections, which are needed before the real chip will work....

Also Proteus will work without decoupling, when the real chip probably won't.
e-learner



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

RE
PostPosted: Wed Jun 11, 2014 12:43 pm     Reply with quote

I understand what u people are saying,but the image shows my realtime connection in bread board,moreover the problem is, the controller is not in run mode even after all the connections basically needed are connected.
pull up res to MCLR,VCC,VSS pin connections,oscillator connection of 20 Mhz crystal with two 33pf capacitors also..wat else have to do? Mad Mad
_________________
e-learner
temtronic



Joined: 01 Jul 2010
Posts: 9204
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:53 pm     Reply with quote

another foobar...

Compiling through MPLAB when in 'debug' mode NOT 'release' mode.

That WILL cause program to NOT run correctly, if at all.....

Post your new program so we can see the changes you made.
It could be a simple typo error.

33pf seems high to me, I generally use 20pfs

hth
jay
dyeatman



Joined: 06 Sep 2003
Posts: 1932
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:54 pm     Reply with quote

If you are using a 20MHZ crystal you should be using HS not XT
Your use delay says 2MHZ not 20MHZ. Which is right?

The quick way to check the LED is disconnect it from the PIC
and connect to directly to VCC to see if it lights.
_________________
Google and Forum Search are some of your best tools!!!!
dbj



Joined: 01 Jun 2014
Posts: 3

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 4:21 pm     Reply with quote

Mike Walne wrote:

If LED is correct way round most of your code is useless.
The LED will turn, on for 5s, off for a few us, repeatedly.
You will not see the turn off.

Mike


Actually, he has a 50k ms delay so that would be 50s.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 4:49 pm     Reply with quote

dbj wrote:
Actually, he has a 50k ms delay so that would be 50s.

Sorry mis-counted the zeros.
Either way the code is silly.

Mike
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 5:41 pm     Reply with quote

I am not sure if am I right, but at least you need to initialize the hardware such as tell uC the port direction Rolling Eyes and after that, you could disconnect the led, just use multimeter to measure if the voltage change on that pin is correct rather than connecting with LED to avoid if the PIN has not enough capability to drive LED.
e-learner



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

RE:
PostPosted: Wed Jun 11, 2014 10:58 pm     Reply with quote

Thanks for all your reply.

got the problem solved,

same silly mistake as most of them do, missed HS declaration in fuse instead i put XT for 20 MHz crystal...... Wink
_________________
e-learner
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Thu Jun 12, 2014 12:59 am     Reply with quote

naughty_mark wrote:
I am not sure if am I right, but at least you need to initialize the hardware such as tell uC the port direction Rolling Eyes and after that, you could disconnect the led, just use multimeter to measure if the voltage change on that pin is correct rather than connecting with LED to avoid if the PIN has not enough capability to drive LED.


No. CCS handles automatically setting the port direction, when 'standard_io' (the default) is used.

The code is silly, but should turn the LED on.

However there are major problems with him apparently having a 20Mhz crystal, but telling the compiler to use a 2Mhz one, and the code not really doing anything worthwhile....
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