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

Trouble getc() ing characters with serial
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 19, 2007 10:43 pm     Reply with quote

Try a simple program below, that echoes back the characters that
you type in to the terminal window. It should work.
Code:

#include <16F876A.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
char c;

while(1)
  {
   c = getc();
   putc(c);
  }

}
lsteele



Joined: 02 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Jan 20, 2007 3:24 am     Reply with quote

Ok, that worked! Thanks.

I'm now going to go step by step adding to your program until I locate the difference that's preventing my version from working.
canuck
Guest







hyperterminal vs. B&B COM test
PostPosted: Sat Feb 10, 2007 10:34 am     Reply with quote

I have also been having problems using getc() with Hyperterminal. When I press a key it seems to bog down, but nothing is echoed back to the screen. Other print statements work fine.

When I use "B&B COM Test" v1.0 everything works fine.


code:

#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
char c;

while(1)
{
c = getc();
putc(c);
}

}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Feb 10, 2007 5:39 pm     Reply with quote

I've had many communication problems related to Hyperterminal. Please save yourself a lot of time and get a decent terminal emulator program.

For example use Siow.exe, provided with your CCS compiler.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sat Feb 10, 2007 7:05 pm     Reply with quote

ckielstra wrote:
I've had many communication problems related to Hyperterminal. Please save yourself a lot of time and get a decent terminal emulator program.
For example use Siow.exe, provided with your CCS compiler.

I really like this one : http://bray.velenje.cx/avr/terminal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 10, 2007 11:44 pm     Reply with quote

There are improved versions of HyperTerminal.
http://www.hilgraeve.com/htpe/index.html
Readme file:
Scroll down to the versions list.
http://www.hilgraeve.com/support/readmes/htpe.html
I've used version 5.0. It looks like they now have a later version.

I'm not saying it's better than the other terminal programs. It's
probably not. But if you did want to have HyperTerminal on your
system and use it occasionally, it's probably better to use this improved
"Private Edition" version.
canuck
Guest







Thanks
PostPosted: Tue Feb 13, 2007 4:59 pm     Reply with quote

Thanks for your suggestions everyone.
Guest








Hmmm...
PostPosted: Mon Mar 26, 2007 5:15 pm     Reply with quote

I'm using a PIC18F4550, and neither gets() or getc() work at all. They continue to just hang.

I've tried everything mentioned here.

I have the proper line driver, etc. For some reason, sometimes it works while other times it won't work. Output is no problem, it's just the input.

Even something as simple as this doesn't work:

#include <18F4550.h>
#device adc=8

#FUSES HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main(void)
{
char key;

printf("This works.\n\r");

key=getc();
putc(key);

printf("We've finally allowed you to get here.\n\r");
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 26, 2007 5:31 pm     Reply with quote

If putc() works and getc() doesn't work, check the wiring.

Is this a board that you built yourself, or is it a manufactured demo board ?
michellelicious



Joined: 15 Apr 2007
Posts: 3

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

To PCM programmer
PostPosted: Tue May 08, 2007 8:45 pm     Reply with quote

PCM programmer wrote:
Try a simple program below, that echoes back the characters that
you type in to the terminal window. It should work.
Code:

#include <16F876A.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
char c;

while(1)
  {
   c = getc();
   putc(c);
  }

}




This does not work for me!!! But why? The code is simple. I can only receive FROM PIC but the pic itself is not getc()ing anything.

CCS 4.013

PIC16f877 and 16f877a
Max232

Hyperterminal and Serial Port monitor

Thanx for any response
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 08, 2007 9:40 pm     Reply with quote

I don't have 4.013, but I do have 4.014. I tested it just now with that
verison, with a 16F877 and a PicDem2-Plus board. It works. It probably
also works with 4.013, because this type of simple program is likely what
CCS used to do some sort of pass-fail test on the version.

If you built your own board, then buy a pre-made board from some company. If you're using Proteus, then buy a real hardware board.
If you built your own serial cable, then buy a cable.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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