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

kbhit never get hit

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



Joined: 12 Aug 2009
Posts: 3

View user's profile Send private message

kbhit never get hit
PostPosted: Wed Aug 12, 2009 4:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 12, 2009 5:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 12, 2009 6:03 am     Reply with quote

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

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

PostPosted: Wed Aug 12, 2009 8:25 am     Reply with quote

Why do you even need a stream when you are using hardware UART?

What do you expect to get back anyway?
daraos_
Guest







RE:
PostPosted: Thu Aug 13, 2009 3:39 pm     Reply with quote

try kbhit(RS485), fgetc(RS485) and fputc(c,RS485)

I had the same problem and I solved it this way
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