|
|
View previous topic :: View next topic |
Author |
Message |
avl094 Guest
|
timed_getc() problem |
Posted: Fri Dec 07, 2007 12:15 pm |
|
|
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
|
|
Posted: Fri Dec 07, 2007 2:59 pm |
|
|
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. |
|
|
|
|
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
|