archanak2511
New Member
Hi,
I've tried this simple embedded C Program using Hi-Tech C for PIC16F877A.
The aim was to obtain a logic high as output on 3 pins (pins D7, D2, D3 of port D), if one input pin (pin B6, of Port B) is driven to logic 1. The program was built successfully but after burning it to the microcontroller I got no result.

Program
Please tell me if there is any mistake in the code or the logic.
Thanks
I've tried this simple embedded C Program using Hi-Tech C for PIC16F877A.
The aim was to obtain a logic high as output on 3 pins (pins D7, D2, D3 of port D), if one input pin (pin B6, of Port B) is driven to logic 1. The program was built successfully but after burning it to the microcontroller I got no result.
Program
Code:
#include<htc.h>
#define _XTAL_FREQ 20000000 //Clock frequecy=20Mhz
main()
{
TRISB=0b11111111; //Set Port B as input port
TRISD=0b00000000; //Set Port D as output port
while(1) //forever loop
{if(RB6==1) //if pin B6 is high
{RD7=1; //set pin D7 as high
RD3=1; //set pin D3 as high
RD2=1; //set pin D2 as high
}
else // if pin B6 is low
{RD7=0; // set pin D7 as low
RD3=0; // set pin D3 as low
RD2=0; //set pin D2 as low
}
}
}
Thanks
Last edited by a moderator: