PIC16f877A Hitech C

Discussion in 'Embedded Systems and Microcontrollers' started by ericyeoh, Oct 26, 2009.

  1. ericyeoh

    Thread Starter Active Member

    Aug 2, 2009
    58
    0
    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?
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    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?
     
  3. russ_hensel

    Well-Known Member

    Jan 11, 2009
    818
    47
    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.
     
  4. ericyeoh

    Thread Starter Active Member

    Aug 2, 2009
    58
    0
    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
     
Loading...