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

18F4620 as a hyperterminal

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







18F4620 as a hyperterminal
PostPosted: Fri Oct 17, 2008 9:49 am     Reply with quote

Hello,

I am very new to micro controllers, and was wondering if this forum can help. I am trying to make a 18F4620 work in both echo mode and respnsive mode, by that I mean, when i type ':' on the hyperterminal I should get an ':' back also I should get the value attached with ':'

Example :

Hyperterminal Input:

:

Hyperterminal output:

::a


I have followed the codes suggested in the links in this website, and formulated my code..and this is as follows ..

Code:

void ui_handle(void)
{
   char c;
   c=fgetc(USER);
   fputc(c,USER);
  c=toupper(c);
   switch(c) {
     
   case ':' :  delay_ms(3000);
                 fputc('a',USER);
                 
               
                  break;
   }
   
  }

////The main Program is as follows

void main() //was previously "void main(void)", Tirtho
{
   enable_interrupts(INT_RDA); //Tirtho
enable_interrupts(GLOBAL); //Tirtho

   
   while (TRUE)
     
   
   }

////////the interrupt program
#int_rda

void rda_isr(void)
{
 
ui_handle();

}   


Looking forward to hearing from you guys..
Cheers

Dave
Guest








PostPosted: Fri Oct 17, 2008 10:43 am     Reply with quote

What, if any, response do you get when you run your code?

Is this a copied and pasted version of your code? I see a few syntax errors that would cause the code to not even compile. You also don't have a #use rs232 statement, so your baud rate is undefined.

Even though it won't give you a compiler error, it is bad practice to use delays in interrupt service routines. If you type two characters within 3 seconds of each other, the second one will be missed, since you are stuck in a 3 second delay. Look at ex_sisr.c in the example folder. Use this int_rda, and bgetc(). don't forget to define bkbhit. Then, in your while(1) loop in the main function, poll bkbhit. If its true, call bgetc. Then do your switch case/delays/echoing. This way, you won't miss received characters.

Also, what program are you using as a terminal? I've had problems using hyperterminal to send characters. I prefer realterm. Everything is configurable, and half duplex is possible.
Newbee
Guest







PostPosted: Fri Oct 17, 2008 10:53 am     Reply with quote

Well yes I have not pasted the whole code. The code compiles and the present output is something like this

Hyperterminal Input:

:


hyperterminal output:

:a

So its not echoing back ':' when it is typed, so thats where the problem arisis. If I concetrate on the echo mode, then the charecter does not get displayed, so its like vice-versa. But I want them both to work together, which is the ultimate solution.

Thanks

Dave
Guest








PostPosted: Fri Oct 17, 2008 11:03 am     Reply with quote

Maybe I'm not understanding the problem.

Do you want hyperterminal to echo the original ':' or the PIC?
Newbee
Guest







PostPosted: Fri Oct 17, 2008 11:08 am     Reply with quote

The PIC, I want the PIC to echo characters sent to it, and respond to the characters which the input is associated with.
Guest








PostPosted: Fri Oct 17, 2008 11:25 am     Reply with quote

Currently, your code is set up to only print one ':', when it echos. So the code is echoing the input ':', but you haven't told it to send the second ':'.
place fputc(':',USER) inside the case ':' construct, above fputc('a',USER)
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