serial communication with labview using pic16f877a
Posted: 16 Jan 2011 15:26
My project is to connect labview and pic 16f877a using serial communication and simulate that on proteus. Using virtual serial port software i connected proteus and labview. I am receiving data from labview but not able to print the data on LCD .I also send the data on portD and connected LED's to it and LED's are turned on but i am not getting a meaningful combination so plz can someone tell me what is wrong with the code.
This is my c code :
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
void main()
{
unsigned char output;
UART1_Init(2400);
Lcd_Init();
TRISB=0;
TRISD=0;
PORTD=0;
PORTB=0;
while(1)
{
if (UART1_Data_Ready() == 1) { // if data is received
output=UART1_Read(); //
PORTD=output;
Delay_ms(100 );
Lcd_Out_Cp(output);
Delay_ms(100);
}
}
}
This is my c code :
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
void main()
{
unsigned char output;
UART1_Init(2400);
Lcd_Init();
TRISB=0;
TRISD=0;
PORTD=0;
PORTB=0;
while(1)
{
if (UART1_Data_Ready() == 1) { // if data is received
output=UART1_Read(); //
PORTD=output;
Delay_ms(100 );
Lcd_Out_Cp(output);
Delay_ms(100);
}
}
}