gopal_kmu54
Newbie level 6
hai to all
I am trying to establish serial port communication . I am connected one loop back at the Female DB-9 which feedbacks the received data back to the controller I get the data on the display. This is the following code i had send which can send two data to two different serial port and recevied from another serial port. kindly suggest me an idea for send and receiving data from two serial ports. I am using ccs c compiler 4.06 version. I am using 16f877A controller.
#include "D:\transinnova\projects\test_two serial port.h"
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B2
#define LCD_RW_PIN PIN_B1
#define LCD_TYPE 2
#use rs232(baud=9600, xmit=PIN_c6,rcv=PIN_c7,stream=com_A)
#use rs232(baud=9600, xmit=PIN_B4,rcv=PIN_B5,stream=com_B)
void lcd_init();
void lcd_cmd(cmd);
void lcd_data(data);
//const (com_A,com_B);
unsigned char cmd,data,b,a,c,d;
void main()
{
set_tris_b(0xF0);
set_tris_d(0x00);
fprintf(com_B,"A");
fprintf(com_B,"B");
c=fgetc(com_B);
d=fgetc(com_B);
data=c;
lcd_init();
delay_ms(1000);
//fputc(d,com_B);
// fputc(d,com_B);
d=getc();
data=d;
lcd_init();
}
void lcd_init()
{
cmd=0x38;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x0E;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x01;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x06;
lcd_cmd(cmd);
delay_us(1640);
lcd_data(data);
return;
}
void lcd_cmd(cmd)
{
output_d(cmd);
output_low(PIN_b2);//rs
output_low(PIN_b1);//read write
output_high(PIN_b0);
delay_us(1640);
output_low(PIN_b0);//enabel
return;
}
void lcd_data(data)
{
output_d(data);
output_high(PIN_b2);//rs
output_low(PIN_b1);//read write
output_high(PIN_b0);
delay_us(1640);
output_low(PIN_b0);//enabel
delay_us(1640);
return;
}
I am trying to establish serial port communication . I am connected one loop back at the Female DB-9 which feedbacks the received data back to the controller I get the data on the display. This is the following code i had send which can send two data to two different serial port and recevied from another serial port. kindly suggest me an idea for send and receiving data from two serial ports. I am using ccs c compiler 4.06 version. I am using 16f877A controller.
#include "D:\transinnova\projects\test_two serial port.h"
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B2
#define LCD_RW_PIN PIN_B1
#define LCD_TYPE 2
#use rs232(baud=9600, xmit=PIN_c6,rcv=PIN_c7,stream=com_A)
#use rs232(baud=9600, xmit=PIN_B4,rcv=PIN_B5,stream=com_B)
void lcd_init();
void lcd_cmd(cmd);
void lcd_data(data);
//const (com_A,com_B);
unsigned char cmd,data,b,a,c,d;
void main()
{
set_tris_b(0xF0);
set_tris_d(0x00);
fprintf(com_B,"A");
fprintf(com_B,"B");
c=fgetc(com_B);
d=fgetc(com_B);
data=c;
lcd_init();
delay_ms(1000);
//fputc(d,com_B);
// fputc(d,com_B);
d=getc();
data=d;
lcd_init();
}
void lcd_init()
{
cmd=0x38;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x0E;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x01;
lcd_cmd(cmd);
delay_us(1640);
cmd=0x06;
lcd_cmd(cmd);
delay_us(1640);
lcd_data(data);
return;
}
void lcd_cmd(cmd)
{
output_d(cmd);
output_low(PIN_b2);//rs
output_low(PIN_b1);//read write
output_high(PIN_b0);
delay_us(1640);
output_low(PIN_b0);//enabel
return;
}
void lcd_data(data)
{
output_d(data);
output_high(PIN_b2);//rs
output_low(PIN_b1);//read write
output_high(PIN_b0);
delay_us(1640);
output_low(PIN_b0);//enabel
delay_us(1640);
return;
}