MPLAB IDE code help

Thread Starter

shinigami.alv

Joined Feb 23, 2011
4
im using 16F877A with MPLAB as compiler but program wont work. previously used ccs and worked fine. my program supposes to light up LED for 2 secs after pressing a button. (used inverter so it's active-high) below is my code:

Rich (BB code):
#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 RD2=0;
 
 if (RC3=1) 
  {
 RD3=1;
 while(RC3=1);
 __delay_ms(2000);
 RD3=0;
 }
 else RD3=0;
 
 
   }

  
}
 

MrChips

Joined Oct 2, 2009
30,824
In all of your if ( ) and while ( )
the proper comparison operator is ==
For example
while ( RC3 == 1)

RC3 = 1 is an assignment operation
RC3 == 1 is a logical operation
 

MrChips

Joined Oct 2, 2009
30,824
__CONFIG(0x3F32) is rather cryptic and doesn't indicate what options are selected.

Use a statement such as:

__CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & DEBUGEN & UNPROTECT);

Your selected setting of 0x3F32 is

__CONFIG( HS & WDTDIS & CPD & CP);


To find out the Configuration bit definitions, look at the the pic16f887.h file found in
in the HI_TECH include folder.
The listing is at the end of the file.
 
Top