Problem With PIC16F886 Port Read[URGENT]

Status
Not open for further replies.

Naren Rover

New Member
Hi Guys.I need help with this Program I'm using PIC16f886 controller
when I press a push Button a LED should blink , the program works fine
the button is connected to pin RB3 and LED to pin RA2.
Problem arises when i set Analog pin
when i enable analog pin AN11 which is in RB4, RB3 is not sensing Button Press.
i have attached the program can someone help me.. thank you

#include <xc.h>
#define BUTTON RB3
#define LED RA2
void main(void)
{
PORTA=0x00;
PORTB=0x00;
TRISA=0x00;
TRISB=0x18; //setting RB4(AN11),RB3 as inputs
ANSEL=0X00;
ANSELH=0X08; // enabling Analog pin AN11 pin
// ANSELH=0X00;
// RB3 senses button when analog pin is disabled which is in RB4
while(1)
{
if(BUTTON==0)
{
LED=1;
}
else
{
LED=0;
}
}

}
 
Can you sketch your circuit... Have you a pullup resistor on RB3?

Is this simulation only?
 
Can't help as I don't do Proteus. Hopefully Ian can help you.

Mike.
 
Okay!!! I think this is a "Protues" issue... ANSELH bit 4 is selecting RB3 instead of RB4..

I have posted a note on Labcenter, Ettore will answer soon... As a quick fix use ANSELH = 0x10; as they seem to match the port bit by mistake.
 
Thanks Ian . I got the Correct output , I did in actual Hardware and it was working fine . the problem was with PROTEUS
 
Just heard back!! There will be a bug fix in the next release.... So Proteus is the guilty party!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…