Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

serial port communication in pc

Status
Not open for further replies.

gopal_kmu54

Newbie level 6
Joined
Feb 1, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,291
Location
india
Activity points
1,395
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;

}
 

Hi,

for gaining more control on serial ports of PIC check following, with down loadable source code

Serial Communications Library -- BoostC and 16F877A


**broken link removed**


at the end the author allows Comment, Questions, Contributions .
 
  • Like
Reactions: mooda

    mooda

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top