Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem in blinking led with 16f877a

Status
Not open for further replies.

hassankhan

New Member
i wrote a program in mikro c & put it into 16f877a, led didnt glow but when i touch one of the probe of multimeter with vdd pin of controller & other with osc2 then it was glowing, what is this?
please tell where i m making mistake??

code is

Code:
void main() {

TRISB = 0; // TO MAKE ALL PORT OUTPUT
     PORTB = 0; // TO OFF PORTB
     while(1)
     {
     PORTB = 0xff; // TO TOGGLE PORTB

     }
}



thanks & regards
hassan khan
 
Last edited by a moderator:
Make sure you have a vcc decoupling capacitor next to the pic power pins. Also make sure you are using the correct oscillator configuration, whether it be crystal, rc or internal. These will require additional capacitors, a resistor and capacitor to operate correctly

Also note that your code to toggle the port pins is incorrect; try using PORTB ^= 0xFF;
 
Make sure you have a vcc decoupling capacitor next to the pic power pins. Also make sure you are using the correct oscillator configuration, whether it be crystal, rc or internal. These will require additional capacitors, a resistor and capacitor to operate correctly

Also note that your code to toggle the port pins is incorrect; try using PORTB ^= 0xFF;

i m not toggling the port just constantly glowing an led
 
yes this on bread board,why sir?


Because the bread board already has capacitance... leave the crystal caps off and try it.. also make sure,as Dougy said, that there is a decoupling cap 0.1μ is across the pic power pins..
 
now i have placed 0.1 uf cap between vdd & vss but still led is not glowing & now when i m placing my one probe on vdd & other on osc2 it is not glowing as well as previously it was,what is it?
 
Have you disabled the WDT? This is done through the configuration bits, or you can leave it enabled and just clear it in the main loop using whatever mikroC's equivalent of asm("clrwdt") is.

If it's still not working, to check if it's just your oscillator setup, you can try using the internal oscillator.
 
Have you disabled the WDT? This is done through the configuration bits, or you can leave it enabled and just clear it in the main loop using whatever mikroC's equivalent of asm("clrwdt") is.

If it's still not working, to check if it's just your oscillator setup, you can try using the internal oscillator.

i am unaware of programming of internal oscillator can u provide me hex file to glow led on portb?
 
Do you have a current-limiting resistor in series with the LED? If not, the LED may be pulling a pin voltage too low.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top