View previous topic :: View next topic |
Author |
Message |
kaimi
Joined: 12 Aug 2009 Posts: 3
|
kbhit never get hit |
Posted: Wed Aug 12, 2009 4:39 am |
|
|
Hello all,
I know this questions was asked many times. But go through all related posts I couldn't found a solution for me.
Here is my code:
Code: |
#include "16F870.h"
#fuses HS, NOWDT, NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, enable=PIN_C5, bits=8, parity=N, errors, stream=RS485)
void main()
{
char c;
printf("Hello world!");
while (1)
{
while (!kbhit());
c = getc();
putc(c);
}
} |
printf() works ("Hello world!" is seen), but kbhit() never get hit.
It is not a hardware problem because I am running the code with a simulation software.
My simulation software worked well with other simulations for other PICs with RS485 test (but not CCS generated code).
I think my program must be wrong somewhere but I can't find out what's wrong.
Anybody have an idea?
I am using CCS 3.221. |
|
|
shashank27187
Joined: 28 Jul 2009 Posts: 13
|
|
Posted: Wed Aug 12, 2009 5:47 am |
|
|
i think u have used RS485 in configuring the rs232 serial in the code while defining the stream...
that would be the problem |
|
|
shashank27187
Joined: 28 Jul 2009 Posts: 13
|
|
Posted: Wed Aug 12, 2009 6:03 am |
|
|
instead of putc(c)
you should try with " fputc(c,RS485)"
as the syntax says:
fputc(variable,stream) |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Wed Aug 12, 2009 8:25 am |
|
|
Why do you even need a stream when you are using hardware UART?
What do you expect to get back anyway? |
|
|
daraos_ Guest
|
RE: |
Posted: Thu Aug 13, 2009 3:39 pm |
|
|
try kbhit(RS485), fgetc(RS485) and fputc(c,RS485)
I had the same problem and I solved it this way |
|
|
|