cheppe32
Newbie level 1
Hi everyone, I am doing a project on home automation system as my final year project. But my mikroc code cannot communicate with PC, when simulate it with proteus it easly communicate with hyperterminal but giving a warning about Configuration bit word. i dont know if thats the reason it cant exchange data with PC. the following is my source code and i am using PIC 16F876A UART connection with RS232 converter.... I'm not a gud programmer nyway!!!
Code:
char cellcommand;
void main() {
TRISB = 0x00;
PORTB = 0x00;
UART1_Init(9600);
Delay_ms(2000);
// Endless loop
while (1) {
// If data is received,
if (UART1_Data_Ready()==1) {
// read the received data,
cellcommand = UART1_Read();
Delay_ms(10);
// and send data via UART
UART1_Write(cellcommand);
PORTB.F4=1;
PORTB.F5=0;
Delay_ms(1000);
}
else if(UART1_Data_Ready()==0){
PORTB.F5=1;
PORTB.F4=0;
Delay_ms(10);
PORTB.F5=0;
Delay_ms(10);
}
//Selecting outputs depending on the recived character
switch(cellcommand){
case 'A': (PORTB.F0=1)&(PORTB.F1=0);
break;
case 'B': (PORTB.F0=1)&(PORTB.F1=1);
break;
case 'C': (PORTB.F0=0)&(PORTB.F1=0);
break;
case 'D': (PORTB.F2=1)&(PORTB.F3=0);
break;
case 'E': (PORTB.F2=1)&(PORTB.F3=1);
break;
case 'F': (PORTB.F2=0)&(PORTB.F3=0);
break;
case 'p': (PORTB.F0=1)&(PORTB.F1=0)&(PORTB.F2=1)&(PORTB.F3=0);
break;
case 'q': (PORTB=0x00);
break;
}
}
}