I need some help using a PIC16F887 and the provided 44-pin demo board from Microchip. Its being programmed with a PicKit2.
On this demo board, there is a push button connected to RB0 in such a way so that the level at the pin is high all the time, and pressing the button drops the level low. The purpose of the push button is to simulate an external interrupt signal. I am trying to experiment with interrupts on this chip but cannot read any status change on this pin.
I have a simple piece of code which tests the status of RB0 and sets RD0 accordingly. However, nothing happens whether or not the button is pressed.
Can anyone see something wrong here? I know the IC itself is fine as I can run other programs that dont use this input pin.
Here is a PDF on the demo board if anyones interested. http://ww1.microchip.com/downloads/en/devicedoc/41296b.pdf
#include <pic16f887.h>
#include <htc.h>
__CONFIG (0x20E4);
__CONFIG (0x2EFF);
void main(void){
int i;
int k;
TRISB = 0xff; //set PORTB as inputs
TRISD = 0x00; // Set PORTD as an Output
while(1)
{
RD0=RB0;
}
I made the following changes as per the solution by Dave below with no change.
void main(void){
int i;
TRISB = 0xff; //set PORTB as inputs
TRISD = 0x00; // Set PORTD as an Output
while(1)
{
i=PORTB;
PORTD=i;
}
}