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

I have noticed that you are doing nothing in your code.... To toggle the port you should use..

Code:
PORTB =~PORTB;
 
877a4.PNG
 
If your circuit is the same as this (with a crystal) it should work..... On a side note.. What speed is your crystal....... If it's 4mhz or below, you need to specify XT crystal setting in your IDE before compilation... If its above, you need to specify HS
 
If your circuit is the same as this (with a crystal) it should work..... On a side note.. What speed is your crystal....... If it's 4mhz or below, you need to specify XT crystal setting in your IDE before compilation... If its above, you need to specify HS

yeah its 4mhz,& i have made that before compilation
do u have any hex file for led at portb?
 
Tons... In my signature..... They are based on Nigel's ASM tutorials and use the same boards.... You build The dev board laid out in Nigel's Pic tutorial site and run all my examples on them.

I also did a MPLAB IDE tutorial with basically the same code as you want.... https://www.electro-tech-online.com/threads/eb08.582/
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top