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

timed_getc() problem

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







timed_getc() problem
PostPosted: Fri Dec 07, 2007 12:15 pm     Reply with quote

PCM 3.6.0.99
MPLAB 7.22

I am trying to use the timed_getc() function as outlined here:
Code:

char timed_getc()
{//timed_getc
   long timeout;
   char retval;

   timeout = 0;
   while(!kbhit() && (++timeout<(KEYHIT_DELAY*100)))
      delay_us(10);
   if(kbhit())
      retval = getc();
   
   else
      retval = 0;
   return(retval);
}//timed_getc


In my main function:
Code:


#include <16F874A.h>

#fuses HS, NOWDT, NOPUT, NOPROTECT, NOLVP, NOBROWNOUT
#use delay(clock = 20000000)
#use rs232(BAUD = 2400, XMIT = PIN_A1, RCV = PIN_A0)
#include <input.c>
#define KEYHIT_DELAY 250 //in milliseconds

void main()
{
while(true)
   {
      
      OUTPUT_C(0x00);   
      OUTPUT_B(0x00);
      OUTPUT_HIGH(run_LED);
      data = timed_getc();
      OUTPUT_B(0xFF);
      if (data == 0xAA) {
      OUTPUT_C(0xFF);}
      delay_ms(500); 

   }
}


When I start the program the serial will not accept input. If I put a getc() before the while() the program will work.
Does anyone have any solutions to this problem?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 07, 2007 2:59 pm     Reply with quote

Quote:
PCM 3.6.0.99

That's not the compiler version. That's the number you see if
you right-click on the CCS compiler icon and look at the version tab.
To find the version, look at the start of the .LST file. This will be in the
project directory and is created after a successful compilation.
The version number will be a 4-digit number such as 3.249, 4.064, etc.


Post a more complete program. For example, you didn't show the
#define statement for 'run_LED'.

Describe the circuit that's connected to Pin A0 on the PIC.
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