This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to receive data from uart using this program

i am editing the program some one already made.i want help to receive the data from uart using the program.here is the interrupt program they have used.

 void serial_interrupt() interrupt 4 using 1
{
        if(RI)
                {
                RI=0;
                com_tmr_rx=5;
                com_r_busy=1;
                //datas[0]=SBUF;
                //datas[com_r_index++]=SBUF;
                if(com_r_index>=34)
                        com_r_index=0;

                }

        if(TI)
                {
                TI=0;
                TX_RX=0;
                if(com_t_index<com_t_length)
                        {
                        TX_RX=1;
                        SBUF=datas[com_t_index++];
                        }
                else
                        {
                        com_t_index=com_t_length=0;
                        TX_RX=0;
                        }

                }

}

.

Parents
  • The most important tool when debugging is the one between your ears - you need to think about what could be causing the problem and, thus, how to fix it.

    Think: What condition is necessary for it to exit the while loop?
    If it isn't exiting the while loop, then that condition is never being fulfilled - so that is the problem which you need to fix!

    Note also that your indentation is misleading. This might be because you have used TABs.
    Never use TABs.
    The interpretation of TABs is entirely unreliable - therefore, use only spaces for indentation.

    Any decent programmer's editor will have the facility to insert the appropriate number of spaces when you press the TAB button; also the facility to convert TABs to spaces.

Reply
  • The most important tool when debugging is the one between your ears - you need to think about what could be causing the problem and, thus, how to fix it.

    Think: What condition is necessary for it to exit the while loop?
    If it isn't exiting the while loop, then that condition is never being fulfilled - so that is the problem which you need to fix!

    Note also that your indentation is misleading. This might be because you have used TABs.
    Never use TABs.
    The interpretation of TABs is entirely unreliable - therefore, use only spaces for indentation.

    Any decent programmer's editor will have the facility to insert the appropriate number of spaces when you press the TAB button; also the facility to convert TABs to spaces.

Children