CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

regarding serial port communication

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gopalakrishnan



Joined: 18 Jun 2010
Posts: 25

View user's profile Send private message

regarding serial port communication
PostPosted: Thu Jul 08, 2010 3:10 am     Reply with quote

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]
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group