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.

pic16f877a input output configuring problem

Status
Not open for further replies.
i am working on PIC16F877A using mikroc compiler and iam facing a problem in knowing the input output configuration of this micro controller.
My task is simple i am monitring the status of a pin at RC1 by making that pin input using TRISC=1(actually i make the whole port input) and by monitring that pin i want that whenever the pin goes high it should on the lED at Pin RB1

here is my code



sbit b at RB1_bit; // to control led at this pin
sbit a at RC1_bit; // to monitor the push button( i connected on end to the vcc and second end to the pin)
void main() {
TRISB=0;
TRISC=1;
while(1)
{

if(a==1)
{
b=1;
}
else
b=0;
}
}

actually iam getting what i want.. but iam confused because when i press the button a yellow light is shown at that pin when iam using simulator that is PROTEUS 7.
why it is yellow? it should be RED(for logic 1).. by default it is BLUE(for logic 0)
 
I don't think you understood my point. You are using bit 1 (RC1) of port C but TRISC=1 makes bit 0 an input not bit 1 as you need.

Mike.
 
I don't think you understood my point. You are using bit 1 (RC1) of port C but TRISC=1 makes bit 0 an input not bit 1 as you need.

Mike.
what i did in my code is..
TRISC=1; // making the whole C port as input( am i right?)
TRISB=0; // making the whole B port as output( am i right?)
now where is the problem?
 
what i did in my code is..
TRISC=1; // making the whole C port as input( am i right?)
TRISB=0; // making the whole B port as output( am i right?)
now where is the problem?


TRISC=1; // equals 00000001 You need TRISC = 255... All pins
 
Status
Not open for further replies.
Back
Top