gopalakrishnan
Joined: 18 Jun 2010 Posts: 25
|
regarding serial port communication |
Posted: Thu Jul 08, 2010 3:10 am |
|
|
ccs compiler version: 4.053
pic ic no:16f877A
hai to all, i tried to establish serial port communication through c4 and c5. where as c4 is the transmit and c5 is receive. Like this way when i loop back the data from c4 and see the received data to the lcd . This is my logic. I already establish communication through c6 and c7 i received the data correctly. Where as i am unable to communicate through c4 and c5. This is my following code. Kindly go through it and give some suggestion.
Code: |
#if defined(__PCM__)
//#include <16F877A.h>
#include <stdio.h>
#include <string.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use standard_io(B)
#use standard_io(C)
#use standard_io(D)
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B2
#define LCD_RW_PIN PIN_B1
#define LCD_TYPE 2
void lcd_init();
void lcd_cmd(cmd);
void lcd_data(data);
unsigned char cmd,data,bv;
void main()
{
set_tris_b(0x00);
set_tris_d(0x00);
//set_tris_c(0x20);
//output_d(0x00);
//output_c(0x00);
//output_b(0x00);
//#USE RS232(BAUD=9600, XMIT=PIN_C4,RCV=PIN_C5)
#USE RS232(BAUD=9600, XMIT=PIN_C6,RCV=PIN_C7)
printf("I");
bv=getc();
data=bv;
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;
} |
thanks in advance
with regards
K.gopalakrishnan
[email protected] |
|