Microcontroller › PIC › Novice at Microcontrollers › Why when I set any port as
November 24, 2012 at 5:36 am
#8786
Ren
Participant
Why when I set any port as input and I write a condition for the output, I get the output regaurdless of thye condition, for the pic16f690. i.e
my code:
#include <htc.h>
#pragma config FOSC=INTRCIO
#pragma config WDTE=OFF
#pragma config PWRTE=OFF
#pragma config MCLRE=ON
#pragma config CP=OFF
#pragma config CPD=OFF
#pragma config BOREN=OFF
#pragma config IESO=OFF
#pragma config FCMEN=OFF
void main(void)
{
ANSEL=0x00;
ANSELH=0x00;
TRISBbits.TRISB4=1;
// TRISAbits.TRISA1=1;
// TRISAbits.TRISA2=1;
// TRISBbits.TRISB5=1;
TRISC=0;
while (1){
if (PORTBbits.RB4=1)
(PORTC=0xff);
}
}
I get Port c lighting up and no input triggered it.