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 support@ccsinfo.com

Making a 18f4620 work like a hyperterminal on echo mode.

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



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Making a 18f4620 work like a hyperterminal on echo mode.
PostPosted: Tue Sep 30, 2008 5:46 pm     Reply with quote

Hi,

I am working with an 18f4620, and I am trying to use its serial port to send data to another embedded system. But I would also like to see the data come back. Similar to the hyperterminal working in echo mode.

I will be seeing the data on the LCD which is connected to another pic which is connected the the 18f4620 using USART.

Thanks

Tranz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 30, 2008 5:49 pm     Reply with quote

See the simple echo program shown in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=27156&start=1
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Wed Oct 01, 2008 12:24 pm     Reply with quote

Thanks PCM !

But if I want to create a response from the micro (18F4620) based on a sentence given by the user, how would I get to do it.

Like if I would like to give a response for

"Would you like to clear the eeprom (y or n) : " and I want the micro to give the response of "y", how do i get to do that. The present program that I am running only takes in characters.

the present code looks something like this..



Code:


void ui_handle(void)
{
   char c;
   c=fgetc(USER);
   c=toupper(c);
   switch(c) {

case 'T':   hardware_test();
                  break;

      case 'D':   ui_settings();
              //delay_ms(3000);
                  break;

      case 'S':   ui_setup();
                  break;

      case 'Z':   clear_ee();
                  fprintf(USER,"\r\nEEPROM Cleared\r\n");
                  break;
}}


void main(void) {

   init();
   splash();
while (TRUE) {
   
   
   if (kbhit(USER))
      {
         ui_handle();
      }
     }
}



USER is the steam for the serial communication and in this case I am using the hardware pins.
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Wed Oct 01, 2008 1:45 pm     Reply with quote

I know fgets would be the best solution for this problem, but when I put it with a stream its showing compiling errors.


Code:

void ui_handle(void)
{
   char c[30];
   char h;
   
   printf("Type 'a' to relock baud-rate: ");
   printf("Erase FLASH? (y/n): ");
   
   c=fgets(USER);

   if (strcmp(c,Type 'a' to relock baud-rate:))
      {
         fprintf(USER,"a");
      }
   if (strcmp(c,Erase FLASH? (y/n):))
      {
         frpintf(USER,"y");
      }
   
                 
   }
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