View previous topic :: View next topic |
Author |
Message |
e-learner
Joined: 20 May 2014 Posts: 21
|
led is off,programming successful...help pls.. |
Posted: Wed Jun 11, 2014 6:59 am |
|
|
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: 19552
|
|
Posted: Wed Jun 11, 2014 7:03 am |
|
|
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
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Jun 11, 2014 8:29 am |
|
|
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: 19552
|
|
Posted: Wed Jun 11, 2014 8:48 am |
|
|
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
|
RE |
Posted: Wed Jun 11, 2014 12:43 pm |
|
|
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? _________________ e-learner |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Wed Jun 11, 2014 12:53 pm |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Wed Jun 11, 2014 12:54 pm |
|
|
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
|
|
Posted: Wed Jun 11, 2014 4:21 pm |
|
|
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
|
|
Posted: Wed Jun 11, 2014 4:49 pm |
|
|
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
|
|
Posted: Wed Jun 11, 2014 5:41 pm |
|
|
I am not sure if am I right, but at least you need to initialize the hardware such as tell uC the port direction 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
|
RE: |
Posted: Wed Jun 11, 2014 10:58 pm |
|
|
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...... _________________ e-learner |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Thu Jun 12, 2014 12:59 am |
|
|
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 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.... |
|
|
|