Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MPLAB IDE code help...

Status
Not open for further replies.

shinigami.alv

Newbie level 4
Joined
Apr 20, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,334
im using 16F877A and my hardware is not working. my program supposes to light up LED for 2 secs after releasing a button. just recently changed to MPLAB. below is my code:
PHP:
#include <pic.h> 
#define _XTAL_FREQ 20000000


void main(void)
{
                   
  
  TRISD = 0b000000;
  TRISC = 0b111111;;

  
 
   while(1)
  {
  
  if (RC2==1) 
  {
 RD2=1;
 while (RC2==1);
 __delay_ms(2000);
 RD2=0;
 }
 

 
 else if (RC3==1) 
  {
 RD3=1;
 while(RC3==1);
 __delay_ms(2000);
 RD3=0;
 }
 
 else PORTD = 255;
 
   }

  
}
 
Last edited:

engmunir

Member level 1
Joined
Sep 24, 2007
Messages
38
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,288
Activity points
1,534
Dear i can provide u assemble code if u want then reply me.
 

Porte

Newbie level 4
Joined
May 1, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
Hi,
May i see the circuit diagram for this project? I also doing the work almost same with your question so it may become my reference. PLEASE...:-D
 

shinigami.alv

Newbie level 4
Joined
Apr 20, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,334
Hi,
May i see the circuit diagram for this project? I also doing the work almost same with your question so it may become my reference. PLEASE...:-D

well, i don't have a circuit diagram with me but it is just simply connecting 5v or gnd (check active low or active high of your MCU) to port c then output port D to LEDs then gnd. ;-) and this code needs to be amended due to some errors.
 

Porte

Newbie level 4
Joined
May 1, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
Ok. I get what you mean. Thanks for your reply. :-D
 

rafeeqmpm

Junior Member level 2
Joined
Apr 16, 2012
Messages
22
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
Malappuram
Activity points
1,388
did you placed the pulldown resistance in RC3 & RC2?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top