PIC16f877A Hitech C

Thread Starter

ericyeoh

Joined Aug 2, 2009
58
hi, i need programmer help me here!
i wrote a program that indicate the input from serial cable.
But my program is using input=getch();
if we use getch function it means it will stuck the whole project and just waiting input from serial! But i dun want this...
So now i hope that got ppl can help me out here avoid this problem !
how to avoid using getch() to get input from serial while my project is running?
 

thatoneguy

Joined Feb 19, 2009
6,359
Use interrupts with the onboard UART to get serial data only when activity is present. See the 877A datasheet for details.

Can you post the code you have have so far?
 

russ_hensel

Joined Jan 11, 2009
825
There is a register ( spec sheet please ) theat indicates that a character is present. You can poll it. Interrupt processing is more reliable, but at your level of skill may be a challange.
 

Thread Starter

ericyeoh

Joined Aug 2, 2009
58
Done !
The datasheet very usefull and the interrupt also success my work!

void interrupt usart(void)
{
if(RCIE&&RCIF)
{
keypress=RCREG; //please decade this to globar decladation and this is the data where The RS232 signal is receive
}
RCIF=0;
}
RCIE=1;
GIE=1;
PEIE=1;
RCSTA=0x90;
TXSTA=0x24;

for more detail pls take a look on the datasheet
 
Top